diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index 067986665..4b4ec77f4 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -706,12 +706,12 @@ void publishEMSValues(bool force) { // see if the heating or hot tap water has changed, if so send // last_boilerActive stores heating in bit 1 and tap water in bit 2 - if ((last_boilerActive != ((EMS_Boiler.tapwaterActive << 1) + EMS_Boiler.heatingActive)) || force) { + if ((last_boilerActive != ((EMS_Boiler.tapwaterActive << 1) | EMS_Boiler.heatingActive)) || force) { myDebugLog("Publishing hot water and heating states via MQTT"); myESP.mqttPublish(TOPIC_BOILER_TAPWATER_ACTIVE, EMS_Boiler.tapwaterActive == 1 ? "1" : "0"); myESP.mqttPublish(TOPIC_BOILER_HEATING_ACTIVE, EMS_Boiler.heatingActive == 1 ? "1" : "0"); - last_boilerActive = ((EMS_Boiler.tapwaterActive << 1) + EMS_Boiler.heatingActive); // remember last state + last_boilerActive = ((EMS_Boiler.tapwaterActive << 1) | EMS_Boiler.heatingActive); // remember last state } // handle the thermostat values @@ -2030,13 +2030,8 @@ void loop() { do_regularUpdates(); publishEMSValues(true); publishSensorValues(true); - _need_first_publish = false; // reset flag - } - - // publish all the values to MQTT - // but only if the values have changed and publish_time is on automatic mode - // always publish when we get the first results, regardless of any publish_time setting - if (EMSESP_Settings.publish_time == 0) { + _need_first_publish = false; // reset flag, so only do this once + } else { publishEMSValues(false); publishSensorValues(false); } diff --git a/src/ems.cpp b/src/ems.cpp index 28d5138b1..4f608fb39 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1272,6 +1272,8 @@ void _checkActive() { if (EMS_Boiler.selFlowTemp != EMS_VALUE_INT_NOTSET && EMS_Boiler.burnGas != EMS_VALUE_INT_NOTSET) { EMS_Boiler.heatingActive = ((EMS_Boiler.selFlowTemp >= EMS_BOILER_SELFLOWTEMP_HEATING) && (EMS_Boiler.burnGas == EMS_VALUE_INT_ON)); } + + EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT } /**