|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
11 #if SUPPORT_HA_DISCOVERY
114 size_t HACover::getDiscoveryJson (
char* buffer,
size_t buflen,
const char* nodeName,
const char* networkName, DynamicJsonDocument* inputJSON) {
116 DynamicJsonDocument outputJSON (1300);
120 if (!nodeName || !networkName || !inputJSON ) {
121 DEBUG_WARN (
"Whrong parameters");
126 outputJSON[
"name"] = String (nodeName) +
"_" + (*inputJSON)[
ha_name_sufix].as<String> ();
128 outputJSON[
"name"] = nodeName;
131 outputJSON[
"unique_id"] = String (nodeName) +
"_" + (*inputJSON)[
ha_name_sufix].as<String> ();
133 outputJSON[
"unique_id"] = nodeName;
135 outputJSON[
"command_topic"] = String (networkName) +
"/" + String (nodeName) +
"/data";
148 outputJSON[
"position_topic"] = String (networkName) +
"/" + String (nodeName) +
"/data";
149 outputJSON[
"position_template"] =
"{{value_json.pos}}";
150 outputJSON[
"set_position_topic"] = String (networkName) +
"/" + String (nodeName) +
"/set/data";
151 String pl_goto =
"pos";
155 outputJSON[
"set_position_template"]= String(
"{\"cmd\":") + pl_goto + String(
"\"pos\":{{position|int}}}");
171 outputJSON[
"state_topic"] = String (networkName) +
"/" + String (nodeName) +
"/data";
172 outputJSON[
"value_template"] =
"{{value_json.state}}";
175 outputJSON[
"json_attributes_topic"] = String (networkName) +
"/" + String (nodeName) +
"/data";
176 outputJSON[
"json_attributes_template"] =
"{{value_json | tojson}}";
179 size_t jsonLen = measureJson (outputJSON);
181 if (jsonLen > buflen) {
182 DEBUG_WARN (
"Too small buffer. Required %u Has %u", jsonLen, buflen);
187 serializeJson (outputJSON, buffer, 1024);
193 switch (sensorClass) {
218 #endif // SUPPORT_HA_DISCOVERY
static size_t getDiscoveryJson(char *buffer, size_t buflen, const char *nodeName, const char *networkName, DynamicJsonDocument *inputJSON)
Allows Gateway to get Home Assistant discovery message using Cover template.
void setStateOpening(const char *payload)
The payload that represents the opening state https://www.home-assistant.io/integrations/cover....
constexpr auto ha_payload_open
constexpr auto ha_device_class
constexpr auto ha_payload_stop
void setStateClosing(const char *payload)
The payload that represents the closing state https://www.home-assistant.io/integrations/cover....
constexpr auto ha_state_open
void setPayloadClose(const char *payload)
The command payload that closes the cover https://www.home-assistant.io/integrations/cover....
constexpr auto ha_state_closing
constexpr auto ha_state_closed
void setPayloadOpen(const char *payload)
The command payload that opens the cover https://www.home-assistant.io/integrations/cover....
constexpr auto ha_allow_attrib
constexpr auto ha_name_sufix
static String deviceClassStr(haCoverClass_t sensorClass)
Gets binary sensor class name from haCoverClass_t https://www.home-assistant.io/integrations/cover....
Home Assistant cover and shade integration.
constexpr auto ha_payload_close
constexpr auto ha_payload_goto
void setDeviceClass(haCoverClass_t devClass)
Define cover class as haCoverClass_t
void setPayloadStop(const char *payload)
The command payload that stops the cover https://www.home-assistant.io/integrations/cover....
constexpr auto ha_state_stopped
void setPayloadGoto(const char *payload)
The command that moves the cover to specific position.
void setStateStopped(const char *payload)
The payload that represents the stopped state https://www.home-assistant.io/integrations/cover....
constexpr auto ha_state_opening
void setStateOpen(const char *payload)
The payload that represents the open state https://www.home-assistant.io/integrations/cover....
void setStateClosed(const char *payload)
The payload that represents the closed state https://www.home-assistant.io/integrations/cover....