|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
17 #if SUPPORT_HA_DISCOVERY
19 #include <ArduinoJson.h>
154 #if DEBUG_LEVEL >= WARN
156 size_t json_len = measureJsonPretty (*
entityConfig) + 1;
157 output = (
char*)malloc (json_len);
160 DEBUG_DBG (
"JSON message\n%s", output);
166 DEBUG_WARN (
"Buffer is null");
173 DEBUG_WARN (
"Too long message. Reduce HA anounce options");
177 if (bufferlen < len) {
178 DEBUG_WARN (
"Buffer is not big enough");
182 len = serializeMsgPack (*
entityConfig, buffer, bufferlen);
183 DEBUG_DBG (
"Msg Pack size: %u", len);
190 DEBUG_DBG (
"Deleted JSON");
228 switch (entityType) {
230 return "alarm_control_panel";
232 return "binary_sensor";
238 return "device_tracker";
240 return "device_automation";
281 DEBUG_WARN (
"Empty prefix");
285 DEBUG_WARN (
"Empty node name");
290 output = String (hassPrefix) +
"/" +
deviceTypeStr (entityType) +
"/" + String (nodeName) +
"_" + String(nameSuffix) +
"/config";
292 output = String (hassPrefix) +
"/" +
deviceTypeStr (entityType) +
"/" + String (nodeName) +
"/config";
301 #endif // SUPPORT_HA_DISCOVERY
303 #endif // _HA_ENTITY_h
constexpr auto ha_payload_open
size_t measureMessage()
Gets needed buffer size for discovery message.
constexpr auto ha_position_closed
DynamicJsonDocument * entityConfig
JSON object to be sent to gateway.
constexpr auto ha_device_class
constexpr auto ha_payload_stop
size_t getAnounceMessage(int bufferlen, uint8_t *buffer)
Gets entity anounce message to be sent over EnigmaIOT message.
constexpr auto ha_state_open
constexpr auto ha_state_closing
static const uint8_t MAX_DATA_PAYLOAD_LENGTH
Maximum EnigmaIOT user data payload size.
char * printHexBuffer(const uint8_t *buffer, uint16_t len)
Debug helper function that generates a string that represent a buffer hexadecimal values.
size_t capacity
JSON object memory reservation length.
constexpr auto ha_state_on
static String getDiscoveryTopic(const char *hassPrefix, const char *nodeName, haDeviceType_t entityType, const char *nameSuffix=NULL)
Allows Gateway to get discovery message MQTT topic.
constexpr auto ha_state_closed
HAEntity()
Default constructor. Needed for inheritance.
constexpr auto ha_allow_attrib
constexpr auto ha_name_sufix
constexpr auto ha_payload
constexpr auto ha_payload_off
constexpr auto ha_expiration
constexpr auto ha_subtype
constexpr auto ha_payload_close
static String deviceTypeStr(haDeviceType_t entityType)
Gets entity type string from haDeviceType_t value https://www.home-assistant.io/docs/mqtt/discovery/.
constexpr auto ha_value_template
constexpr auto ha_payload_goto
constexpr auto ha_position_open
constexpr auto ha_state_off
constexpr auto ha_state_stopped
constexpr auto ha_unit_of_measurement
constexpr auto ha_device_type
haDeviceType_t deviceType
HomeAssistant entity device type.
constexpr auto ha_payload_on
Auxiliary function definition.
void setNameSufix(const char *payload)
Sets name suffix. Used for multi entity nodes.
Auxiliary functions for debugging over Serial.
constexpr auto ha_state_opening
void allowSendAttributes()
Enables registering entity attributes as a json object.
constexpr auto ha_set_position_template
constexpr auto ha_off_delay
constexpr auto ha_value_key