diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index a23efce2d..6851ed9e4 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -42,7 +42,7 @@ static const __FlashStringHelper * DeviceValueUOM_s[] __attribute__((__aligned__ static const __FlashStringHelper * const DeviceValueTAG_s[] PROGMEM = { F_(tag_none), // "" - F_(tag_system_data), // "" + F_(tag_heartbeat), // "" F_(tag_boiler_data), // "" F_(tag_boiler_data_ww), // "warm water" F_(tag_thermostat_data), // "" @@ -61,7 +61,7 @@ static const __FlashStringHelper * const DeviceValueTAG_s[] PROGMEM = { static const __FlashStringHelper * const DeviceValueTAG_mqtt[] PROGMEM = { F_(tag_none), // "" - F_(tag_system_data_mqtt), // "heartbeat" + F_(tag_heartbeat_mqtt), // "heartbeat" F_(tag_boiler_data_mqtt), // "" F_(tag_boiler_data_ww_mqtt), // "ww" F_(tag_thermostat_data), // "" diff --git a/src/emsdevice.h b/src/emsdevice.h index cd6b04b98..6d7cf71c7 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -71,7 +71,7 @@ enum DeviceValueUOM : uint8_t { NONE = 0, DEGREES, PERCENT, LMIN, KWH, WH, HOURS // TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp // use empty string if want to suppress showing tags MAKE_PSTR(tag_none, "") -MAKE_PSTR(tag_system_data, "") +MAKE_PSTR(tag_heartbeat, "") MAKE_PSTR(tag_boiler_data, "") MAKE_PSTR(tag_boiler_data_ww, "warm water") MAKE_PSTR(tag_thermostat_data, "") @@ -85,13 +85,13 @@ MAKE_PSTR(tag_wwc3, "wwc3") MAKE_PSTR(tag_wwc4, "wwc4") // MQTT topic names -MAKE_PSTR(tag_system_data_mqtt, "heartbeat") +MAKE_PSTR(tag_heartbeat_mqtt, "heartbeat") MAKE_PSTR(tag_boiler_data_mqtt, "") MAKE_PSTR(tag_boiler_data_ww_mqtt, "ww") enum DeviceValueTAG : uint8_t { TAG_NONE = 0, // wild card - TAG_SYSTEM_DATA, + TAG_HEARTBEAT, TAG_BOILER_DATA, TAG_BOILER_DATA_WW, TAG_THERMOSTAT_DATA, diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 53bec453d..4f97b4cb6 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -599,16 +599,16 @@ void Mqtt::ha_status() { Mqtt::publish_ha(topic, doc.as()); // publish the config payload with retain flag // create the sensors - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("Wifi strength"), EMSdevice::DeviceType::SYSTEM, F("rssi")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("Uptime (sec)"), EMSdevice::DeviceType::SYSTEM, F("uptime_sec")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("Free heap memory"), EMSdevice::DeviceType::SYSTEM, F("freemem")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Failed MQTT publishes"), EMSdevice::DeviceType::SYSTEM, F("mqttfails")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Rx Sent"), EMSdevice::DeviceType::SYSTEM, F("rxsent")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Rx Fails"), EMSdevice::DeviceType::SYSTEM, F("rxfails")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Tx Reads"), EMSdevice::DeviceType::SYSTEM, F("txread")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Tx Writes"), EMSdevice::DeviceType::SYSTEM, F("txwrite")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_SYSTEM_DATA, F("# Tx Fails"), EMSdevice::DeviceType::SYSTEM, F("txfails")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Wifi strength"), EMSdevice::DeviceType::SYSTEM, F("rssi")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime (sec)"), EMSdevice::DeviceType::SYSTEM, F("uptime_sec")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Free heap memory"), EMSdevice::DeviceType::SYSTEM, F("freemem")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Failed MQTT publishes"), EMSdevice::DeviceType::SYSTEM, F("mqttfails")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Rx Sent"), EMSdevice::DeviceType::SYSTEM, F("rxsent")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Rx Fails"), EMSdevice::DeviceType::SYSTEM, F("rxfails")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Tx Reads"), EMSdevice::DeviceType::SYSTEM, F("txread")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Tx Writes"), EMSdevice::DeviceType::SYSTEM, F("txwrite")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Tx Fails"), EMSdevice::DeviceType::SYSTEM, F("txfails")); } // add sub or pub task to the queue. @@ -916,6 +916,7 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice // differs based on whether MQTT nested is enabled // tag = EMSdevice::DeviceValueTAG const std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) { + // the system device is treated differently. The topic is 'heartbeat' and doesn't follow the usual convention if (device_type == EMSdevice::DeviceType::SYSTEM) { return EMSdevice::tag_to_mqtt(tag); }