mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
prevent MQTT sending out HA configs for dormant heating circuits - #288
This commit is contained in:
@@ -442,6 +442,11 @@ void Thermostat::publish_values() {
|
|||||||
Mqtt::publish(topic, doc);
|
Mqtt::publish(topic, doc);
|
||||||
rootThermostat = doc.to<JsonObject>(); // clear object
|
rootThermostat = doc.to<JsonObject>(); // clear object
|
||||||
} else if (mqtt_format_ == MQTT_format::HA) {
|
} else if (mqtt_format_ == MQTT_format::HA) {
|
||||||
|
// see if we have already registered this with HA MQTT Discovery, if not send the config
|
||||||
|
if (!hc->ha_registered()) {
|
||||||
|
register_mqtt_ha_config(hc->hc_num());
|
||||||
|
}
|
||||||
|
// send the thermostat topic and payload data
|
||||||
std::string topic(100, '\0');
|
std::string topic(100, '\0');
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("homeassistant/climate/ems-esp/hc%d/state"), hc->hc_num());
|
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("homeassistant/climate/ems-esp/hc%d/state"), hc->hc_num());
|
||||||
Mqtt::publish(topic, doc);
|
Mqtt::publish(topic, doc);
|
||||||
@@ -529,11 +534,6 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
|
|||||||
|
|
||||||
std::sort(heating_circuits_.begin(), heating_circuits_.end()); // sort based on hc number
|
std::sort(heating_circuits_.begin(), heating_circuits_.end()); // sort based on hc number
|
||||||
|
|
||||||
// if we're using Home Assistant and HA discovery, register the new config
|
|
||||||
if (mqtt_format_ == MQTT_format::HA) {
|
|
||||||
register_mqtt_ha_config(hc_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the flag saying we want its data during the next auto fetch
|
// set the flag saying we want its data during the next auto fetch
|
||||||
toggle_fetch(monitor_typeids[hc_num - 1], toggle_);
|
toggle_fetch(monitor_typeids[hc_num - 1], toggle_);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class Thermostat : public EMSdevice {
|
|||||||
class HeatingCircuit {
|
class HeatingCircuit {
|
||||||
public:
|
public:
|
||||||
HeatingCircuit(const uint8_t hc_num)
|
HeatingCircuit(const uint8_t hc_num)
|
||||||
: hc_num_(hc_num) {
|
: hc_num_(hc_num)
|
||||||
|
, ha_registered_(false) {
|
||||||
}
|
}
|
||||||
~HeatingCircuit() = default;
|
~HeatingCircuit() = default;
|
||||||
|
|
||||||
@@ -65,6 +66,10 @@ class Thermostat : public EMSdevice {
|
|||||||
return hc_num_;
|
return hc_num_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ha_registered() const {
|
||||||
|
return ha_registered_;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t get_mode(uint8_t flags) const;
|
uint8_t get_mode(uint8_t flags) const;
|
||||||
uint8_t get_mode_type(uint8_t flags) const;
|
uint8_t get_mode_type(uint8_t flags) const;
|
||||||
|
|
||||||
@@ -76,7 +81,8 @@ class Thermostat : public EMSdevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t hc_num_; // 1..10
|
uint8_t hc_num_; // heating circuit number 1..10
|
||||||
|
bool ha_registered_; // whether it has been registered for HA MQTT Discovery
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string mode_tostring(uint8_t mode);
|
static std::string mode_tostring(uint8_t mode);
|
||||||
@@ -109,7 +115,7 @@ class Thermostat : public EMSdevice {
|
|||||||
|
|
||||||
// Installation parameters
|
// Installation parameters
|
||||||
uint8_t ibaMainDisplay_ =
|
uint8_t ibaMainDisplay_ =
|
||||||
EMS_VALUE_UINT_NOTSET; // display on Thermostat: 0 int. temp, 1 int. setpoint, 2 ext. temp., 3 burner temp., 4 ww temp, 5 functioning mode, 6 time, 7 data, 9 smoke temp
|
EMS_VALUE_UINT_NOTSET; // display on Thermostat: 0 int temp, 1 int setpoint, 2 ext temp, 3 burner temp, 4 ww temp, 5 functioning mode, 6 time, 7 data, 9 smoke temp
|
||||||
uint8_t ibaLanguage_ = EMS_VALUE_UINT_NOTSET; // language on Thermostat: 0 german, 1 dutch, 2 french, 3 italian
|
uint8_t ibaLanguage_ = EMS_VALUE_UINT_NOTSET; // language on Thermostat: 0 german, 1 dutch, 2 french, 3 italian
|
||||||
int8_t ibaCalIntTemperature_ = EMS_VALUE_INT_NOTSET; // offset int. temperature sensor, by * 0.1 Kelvin (-5.0 to 5.0K)
|
int8_t ibaCalIntTemperature_ = EMS_VALUE_INT_NOTSET; // offset int. temperature sensor, by * 0.1 Kelvin (-5.0 to 5.0K)
|
||||||
int8_t ibaMinExtTemperature_ = EMS_VALUE_INT_NOTSET; // min ext temp for heating curve, in deg., 0xF6=-10, 0x0 = 0, 0xFF=-1
|
int8_t ibaMinExtTemperature_ = EMS_VALUE_INT_NOTSET; // min ext temp for heating curve, in deg., 0xF6=-10, 0x0 = 0, 0xFF=-1
|
||||||
|
|||||||
Reference in New Issue
Block a user