typedefenum// Enumeration of binary sensor types supported by the Home Assistant. For details see https://www.home-assistant.io/integrations/binary_sensor/#device-class.
zh_device_type_tdevice_type;// Type of ESP-NOW message sender (gateway, switch, led, etc…).
zh_payload_type_tpayload_type;// Type of payload for indicating to the recipient of the message into which required structure the received data should be converted (if required).
union// Main union for data exchange between ESP-NOW devices. @attention Usually not used in this view. According to the device_type data and payload_type data, the ESP-NOW device should convert the payload_data to the required secondary structure/union (excluding the case of having to send an empty message).
{
struct// Secondary structure of attributes message.
{
ha_chip_type_tchip_type;// Used ESP module type.
ha_sensor_type_tsensor_type;// Used sensor/binary sensor type (if present).
struct// Secondary structure of keep alive message.
{
boolonline_status;// Current status of ESP-NOW device operation. @note Online (true) / Offline (false).
uint8_tmessage_frequency;// Frequency of transmission of the keep alive message by ESP-NOW device. @note Used by the ESP-NOW gateway to set the offline status of a ESP-NOW node when the message sending time is exceeded.
}keep_alive_message;
union// Secondary union of structures of any configuration messages. @attention Not used in this view. Should be converted to the required tertiary structure.
{
struct// Tertiary structure of zh_espnow_binary_sensor node configuration message. @note Used for publish at MQTT zh_espnow_binary_sensor node configuration message.
{
uint8_tunique_id;// An ID that uniquely identifies this binary sensor device. @note The ID will look like this - "MAC-X" (for example 64-B7-08-31-00-A8-1). @attention If two binary sensors have the same unique ID, Home Assistant will raise an exception.
ha_binary_sensor_device_class_tbinary_sensor_device_class;// Binary sensor type supported by the Home Assistant. @note Used to prepare a correct configuration message for Home Assistant MQTT discovery. For details see https://www.home-assistant.io/integrations/binary_sensor.
ha_on_off_type_tpayload_on;// The payload that represents ON state.
ha_on_off_type_tpayload_off;// The payload that represents OFF state.
uint16_texpire_after;// If set, it defines the number of seconds after the sensors state expires, if its not updated. After expiry, the sensors state becomes unavailable.
uint16_toff_delay;// For sensors that only send on state updates (like PIRs), this variable sets a delay in seconds after which the sensors state will be updated back to off.
boolenabled_by_default;// Flag which defines if the entity should be enabled when first added.
boolforce_update;// Sends update events (which results in update of state objects last_changed) even if the sensors state hasnt changed. Useful if you want to have meaningful value graphs in history or want to create an automation that triggers on every incoming state message (not only when the sensors new state is different to the current one).
uint8_tqos;// The maximum QoS level to be used when receiving and publishing messages.
boolretain;// If the published message should have the retain flag on or not.
}binary_sensor_config_message;
struct// Tertiary structure of zh_espnow_sensor node configuration message. @note Used publish at MQTT zh_espnow_sensor node configuration message.
{
uint8_tunique_id;// An ID that uniquely identifies this sensor device. @note The ID will look like this - "MAC-X" (for example 64-B7-08-31-00-A8-1). @attention If two sensors have the same unique ID, Home Assistant will raise an exception.
ha_sensor_device_class_tsensor_device_class;// Sensor type supported by the Home Assistant. @note Used to prepare a correct configuration message for Home Assistant MQTT discovery. For details see https://www.home-assistant.io/integrations/sensor.
charunit_of_measurement[5];// Defines the units of measurement of the sensor, if any.
uint8_tsuggested_display_precision;// The number of decimals which should be used in the sensors state after rounding.
uint16_texpire_after;// If set, it defines the number of seconds after the sensors state expires, if its not updated. After expiry, the sensors state becomes unavailable.
boolenabled_by_default;// Flag which defines if the entity should be enabled when first added.
boolforce_update;// Sends update events (which results in update of state objects last_changed) even if the sensors state hasnt changed. Useful if you want to have meaningful value graphs in history or want to create an automation that triggers on every incoming state message (not only when the sensors new state is different to the current one).
uint8_tqos;// The maximum QoS level to be used when receiving and publishing messages.
boolretain;// If the published message should have the retain flag on or not.
}sensor_config_message;
struct// Tertiary structure of zh_espnow_sensor node hardware configuration message. @note Used for change hardware configuration / publish at MQTT zh_espnow_sensor node hardware configuration message.
{
ha_sensor_type_tsensor_type;// Sensor types. @note Used in zh_espnow_sensor firmware only.
uint8_tsensor_pin_1;// Sensor GPIO number 1. @note Main pin for 1-wire sensors, SDA pin for I2C sensors.
uint8_tsensor_pin_2;// Sensor GPIO number 2. @note SCL pin for I2C sensors.
uint8_tpower_pin;// Power GPIO number (if used sensor power control).
uint16_tmeasurement_frequency;// Measurement frequency (sleep time on battery powering).
struct// Tertiary structure of zh_espnow_led node configuration message. @note Used for publish at MQTT zh_espnow_led node configuration message.
{
uint8_tunique_id;// An ID that uniquely identifies this light device. @note The ID will look like this - "MAC-X" (for example 64-B7-08-31-00-A8-1). @attention If two lights have the same unique ID, Home Assistant will raise an exception.
ha_led_type_tled_type;// Led type. @note Used to identify the led type by ESP-NOW gateway and prepare a correct configuration message for Home Assistant MQTT discovery.
ha_on_off_type_tpayload_on;// The payload that represents ON state.
ha_on_off_type_tpayload_off;// The payload that represents OFF state.
boolenabled_by_default;// Flag which defines if the entity should be enabled when first added.
booloptimistic;// Flag that defines if led works in optimistic mode.
uint8_tqos;// The maximum QoS level to be used when receiving and publishing messages.
boolretain;// If the published message should have the retain flag on or not.
}led_config_message;
struct// Tertiary structure of zh_espnow_led node hardware configuration message. @note Used for change hardware configuration / publish at MQTT zh_espnow_led node hardware configuration message.
{
ha_led_type_tled_type;// Led types. @note Used in zh_espnow_led firmware only.
uint8_tfirst_white_pin;// First white GPIO number.
uint8_tsecond_white_pin;// Second white GPIO number (if present).
uint8_tred_pin;// Red GPIO number (if present).
uint8_tgreen_pin;// Green GPIO number (if present).
uint8_tblue_pin;// Blue GPIO number (if present).
}led_hardware_config_message;
struct// Tertiary structure of zh_espnow_switch node configuration message. @note Used for publish at MQTT zh_espnow_switch node configuration message.
{
uint8_tunique_id;// An ID that uniquely identifies this switch device. @note The ID will look like this - "MAC-X" (for example 64-B7-08-31-00-A8-1). @attention If two switches have the same unique ID, Home Assistant will raise an exception.
ha_switch_device_class_tdevice_class;// Switch type supported by the Home Assistant. @note Used to prepare a correct configuration message for Home Assistant MQTT discovery. For details see https://www.home-assistant.io/integrations/switch
ha_on_off_type_tpayload_on;// The payload that represents ON state.
ha_on_off_type_tpayload_off;// The payload that represents OFF state.
boolenabled_by_default;// Flag which defines if the entity should be enabled when first added.
booloptimistic;// Flag that defines if switch works in optimistic mode.
uint8_tqos;// The maximum QoS level to be used when receiving and publishing messages.
boolretain;// If the published message should have the retain flag on or not.
}switch_config_message;
struct// Tertiary structure of zh_espnow_switch node hardware configuration message. @note Used for change hardware configuration / publish at MQTT zh_espnow_switch node hardware configuration message.
{
uint8_trelay_pin;// Relay GPIO number.
boolrelay_on_level;// Relay ON level. @note HIGH (true) / LOW (false).
uint8_tled_pin;// Led GPIO number (if present).
boolled_on_level;// Led ON level (if present). @note HIGH (true) / LOW (false).
uint8_tint_button_pin;// Internal button GPIO number (if present).
uint8_tsensor_pin;// Sensor GPIO number (if present).
ha_sensor_type_tsensor_type;// Sensor types (if present). @note Used to identify the sensor type by ESP-NOW gateway and send the appropriate sensor status messages to MQTT.
}switch_hardware_config_message;
}config_message;
union// Secondary union of structures of any status messages. @attention Not used in this view. Should be converted to the required tertiary structure.
{
struct// Tertiary structure of zh_espnow_binary_sensor node status message.
{
ha_sensor_type_tsensor_type;// Binary sensor types. @note Used to identify the binary sensor type by ESP-NOW gateway and send the appropriate binary sensor status messages to MQTT.
ha_on_off_type_tconnect;// Event that caused the sensor to be triggered (if present). @note Example - CONNECT @attention Must be same with set on binary_sensor_config_message structure.
ha_on_off_type_topen;// Event that caused the sensor to be triggered (if present). @note Example - OPEN / CLOSE @attention Must be same with set on binary_sensor_config_message structure.
ha_on_off_type_tbattery;// Event that caused the sensor to be triggered (if present). @note Example - HIGH / LOW @attention Must be same with set on binary_sensor_config_message structure.
ha_on_off_type_tleakage;// Event that caused the sensor to be triggered (if present). @note Example - DRY / LEAKAGE @attention Must be same with set on binary_sensor_config_message structure.
ha_on_off_type_treserved_1;// Reserved for future development.
ha_on_off_type_treserved_2;// Reserved for future development.
ha_on_off_type_treserved_3;// Reserved for future development.
ha_on_off_type_treserved_4;// Reserved for future development.
ha_on_off_type_treserved_5;// Reserved for future development.
}binary_sensor_status_message;
struct// Tertiary structure of zh_espnow_sensor node status message.
{
ha_sensor_type_tsensor_type;// Sensor types. @note Used to identify the sensor type by ESP-NOW gateway and send the appropriate sensor status messages to MQTT.
floattemperature;// Temperature value (if present).
floathumidity;// Humidity value (if present).
floatpressure;// Pressure value (if present).
floatquality;// Quality value (if present).
floatvoltage;// Voltage value (if present).
floatreserved_1;// Reserved for future development.
floatreserved_2;// Reserved for future development.
floatreserved_3;// Reserved for future development.
floatreserved_4;// Reserved for future development.
floatreserved_5;// Reserved for future development.
}sensor_status_message;
struct// Tertiary structure of zh_espnow_led node status message.
{
ha_on_off_type_tstatus;// Status of the zh_espnow_led. @note Example - ON / OFF. @attention Must be same with set on led_config_message structure.
uint8_tbrightness;// Brightness value.
uint16_ttemperature;// White color temperature value (if present).
uint8_tred;// Red color value (if present).
uint8_tgreen;// Green color value (if present).
uint8_tblue;// Blue color value (if present).
ha_led_effect_type_teffect;// Reserved for future development.
}led_status_message;
struct// Tertiary structure of zh_espnow_switch node status message.
{
ha_on_off_type_tstatus;// Status of the zh_espnow_switch. @note Example - ON / OFF. @attention Must be same with set on switch_config_message structure.
}switch_status_message;
}status_message;
union// Secondary union of structures of any OTA update messages. @attention Not used in this view. Should be converted to the required tertiary structure.
{
struct// Tertiary structure for transfer from ESP-NOW node to ESP-NOW gateway system information for OTA update initialization.