mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fixes Excluding thermostat entities should also remove the climate discovery topic #368
This commit is contained in:
@@ -245,7 +245,8 @@ class EMSdevice {
|
|||||||
void publish_value(void * value);
|
void publish_value(void * value);
|
||||||
void publish_all_values();
|
void publish_all_values();
|
||||||
|
|
||||||
void publish_mqtt_ha_entity_config();
|
void mqtt_ha_entity_config_create();
|
||||||
|
void mqtt_ha_entity_config_remove();
|
||||||
|
|
||||||
const std::string telegram_type_name(std::shared_ptr<const Telegram> telegram);
|
const std::string telegram_type_name(std::shared_ptr<const Telegram> telegram);
|
||||||
|
|
||||||
|
|||||||
@@ -560,13 +560,18 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
|||||||
// group by device type
|
// group by device type
|
||||||
for (const auto & emsdevice : emsdevices) {
|
for (const auto & emsdevice : emsdevices) {
|
||||||
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
||||||
// specially for HA
|
// specially for MQTT Discovery
|
||||||
// we may have some RETAINED /config topics that reference fields in the data payloads that no longer exist
|
// we may have some RETAINED /config topics that reference fields in the data payloads that no longer exist
|
||||||
// remove them immediately to prevent HA from complaining
|
// remove them immediately to prevent HA from complaining
|
||||||
// we need to do this first before the data payload is published, and only done once!
|
// we need to do this first before the data payload is published, and only done once!
|
||||||
if (Mqtt::ha_enabled() && emsdevice->ha_config_firstrun()) {
|
if (Mqtt::ha_enabled()) {
|
||||||
|
if (emsdevice->ha_config_firstrun()) {
|
||||||
emsdevice->ha_config_clear();
|
emsdevice->ha_config_clear();
|
||||||
emsdevice->ha_config_firstrun(false);
|
emsdevice->ha_config_firstrun(false);
|
||||||
|
} else {
|
||||||
|
// see if we need to delete and /config topics before adding the payloads
|
||||||
|
emsdevice->mqtt_ha_entity_config_remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if its a boiler, generate json for each group and publish it directly. not nested
|
// if its a boiler, generate json for each group and publish it directly. not nested
|
||||||
@@ -627,7 +632,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
|||||||
|
|
||||||
// we want to create the /config topic after the data payload to prevent HA from throwing up a warning
|
// we want to create the /config topic after the data payload to prevent HA from throwing up a warning
|
||||||
if (Mqtt::ha_enabled()) {
|
if (Mqtt::ha_enabled()) {
|
||||||
emsdevice->publish_mqtt_ha_entity_config();
|
emsdevice->mqtt_ha_entity_config_create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user