mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
ensure heating_active and tapwater_active MQTT topics are sent on cold start
This commit is contained in:
@@ -97,8 +97,8 @@ void Boiler::register_mqtt_ha_config() {
|
||||
ids.add("ems-esp-boiler");
|
||||
Mqtt::publish_retain(F("homeassistant/sensor/ems-esp/boiler/config"), doc.as<JsonObject>(), true); // publish the config payload with retain flag
|
||||
|
||||
Mqtt::register_mqtt_ha_binary_sensor(F_(tapwaterActive), this->device_type(), "tapwaterActive");
|
||||
Mqtt::register_mqtt_ha_binary_sensor(F_(heatingActive), this->device_type(), "heatingActive");
|
||||
Mqtt::register_mqtt_ha_binary_sensor(F_(tapwaterActive), this->device_type(), "tapwater_active");
|
||||
Mqtt::register_mqtt_ha_binary_sensor(F_(heatingActive), this->device_type(), "heating_active");
|
||||
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(serviceCodeNumber), this->device_type(), "serviceCodeNumber", nullptr, nullptr);
|
||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWSelTemp), this->device_type(), "wWSelTemp", F_(degrees), F_(icontemperature));
|
||||
@@ -604,7 +604,7 @@ void Boiler::publish_values() {
|
||||
Mqtt::publish(F("boiler_data"), doc.as<JsonObject>());
|
||||
}
|
||||
|
||||
// send out heating and tapwater status - even if there is no change (force = true)
|
||||
// send out heating and tapwater status
|
||||
check_active();
|
||||
}
|
||||
|
||||
@@ -711,14 +711,14 @@ void Boiler::show_values(uuid::console::Shell & shell) {
|
||||
* If a value has changed, post it immediately to MQTT so we get real time data
|
||||
*/
|
||||
void Boiler::check_active() {
|
||||
if ((boilerState_ & 0x09) != (last_boilerState & 0x09)) {
|
||||
if ((boilerState_ == EMS_VALUE_UINT_NOTSET) || ((boilerState_ & 0x09) != (last_boilerState & 0x09))) {
|
||||
char s[7];
|
||||
bool b = ((boilerState_ & 0x09) == 0x09);
|
||||
Mqtt::publish(F("heating_active"), Helpers::render_boolean(s, b));
|
||||
heatingActive_ = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
||||
}
|
||||
|
||||
if ((boilerState_ & 0x0A) != (last_boilerState & 0x0A)) {
|
||||
if ((boilerState_ == EMS_VALUE_UINT_NOTSET) || ((boilerState_ & 0x0A) != (last_boilerState & 0x0A))) {
|
||||
char s[7];
|
||||
bool b = ((boilerState_ & 0x0A) == 0x0A);
|
||||
Mqtt::publish(F("tapwater_active"), Helpers::render_boolean(s, b));
|
||||
|
||||
@@ -52,7 +52,7 @@ class Boiler : public EMSdevice {
|
||||
|
||||
void print_value2(uuid::console::Shell & shell, const char * param, const __FlashStringHelper * name, const __FlashStringHelper * suffix, JsonObject & json);
|
||||
|
||||
uint8_t last_boilerState = 0xFF; // remember last state of heating and warm water on/off
|
||||
uint8_t last_boilerState = EMS_VALUE_UINT_NOTSET; // remember last state of heating and warm water on/off
|
||||
bool changed_ = false;
|
||||
bool mqtt_ha_config_ = false; // HA MQTT Discovery
|
||||
|
||||
@@ -97,7 +97,7 @@ class Boiler : public EMSdevice {
|
||||
uint8_t sysPress_ = EMS_VALUE_UINT_NOTSET; // System pressure
|
||||
char serviceCode_[3] = {'\0'}; // 2 character status/service code
|
||||
uint16_t serviceCodeNumber_ = EMS_VALUE_USHORT_NOTSET; // error/service code
|
||||
uint8_t boilerState_ = EMS_VALUE_BOOL_NOTSET; // State flag, used on HT3
|
||||
uint8_t boilerState_ = EMS_VALUE_UINT_NOTSET; // Boiler state flag
|
||||
|
||||
// UBAMonitorSlow - 0x19 on EMS1
|
||||
int16_t outdoorTemp_ = EMS_VALUE_SHORT_NOTSET; // Outside temperature
|
||||
|
||||
Reference in New Issue
Block a user