mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix HA climate
This commit is contained in:
@@ -675,19 +675,18 @@ void Thermostat::add_ha_climate(std::shared_ptr<HeatingCircuit> hc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_values = Helpers::hasValue(hc->selTemp) && Helpers::hasValue(hc->roomTemp);
|
|
||||||
|
|
||||||
// see if we need to remove the HA climate component because some of the values have been lost
|
|
||||||
// note, this doesn't account for whether any of the device values have been excluded
|
// note, this doesn't account for whether any of the device values have been excluded
|
||||||
if (hc->ha_climate_created() && !has_values) {
|
if (hc->ha_climate_created()) {
|
||||||
// remove the whole climate component
|
// see if we've lost the selTemp (roomTemp/currTemp is optional and checked in the publish_ha_config_hc() function)
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
if (!Helpers::hasValue(hc->selTemp)) {
|
||||||
snprintf(topic, sizeof(topic), "climate/%s/thermostat_hc%d/config", Mqtt::base().c_str(), hc->hc_num());
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
Mqtt::publish_ha(topic);
|
snprintf(topic, sizeof(topic), "climate/%s/thermostat_hc%d/config", Mqtt::base().c_str(), hc->hc_num());
|
||||||
|
Mqtt::publish_ha(topic);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// create
|
// create the climate component, only once
|
||||||
publish_ha_config_hc(hc);
|
publish_ha_config_hc(hc);
|
||||||
hc->ha_climate_created(true); // only create it once
|
hc->ha_climate_created(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user