From f3d52f493258a66dafeabc603ddba194fe0a353a Mon Sep 17 00:00:00 2001 From: ezcGman Date: Mon, 19 Dec 2022 22:30:11 +0100 Subject: [PATCH] UM SHT: MQTT re-publish values on unit change --- usermods/sht/usermod_sht.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usermods/sht/usermod_sht.h b/usermods/sht/usermod_sht.h index 88daeb43..652bdfde 100644 --- a/usermods/sht/usermod_sht.h +++ b/usermods/sht/usermod_sht.h @@ -387,6 +387,7 @@ bool ShtUsermod::readFromConfig(JsonObject &root) bool oldEnabled = enabled; byte oldShtType = shtType; + byte oldUnitOfTemp = unitOfTemp; bool oldHaMqttDiscovery = haMqttDiscovery; getJsonValue(top[FPSTR(_enabled)], enabled); @@ -410,6 +411,11 @@ bool ShtUsermod::readFromConfig(JsonObject &root) initShtTempHumiditySensor(); } + if (oldUnitOfTemp != unitOfTemp) { + publishTemperatureAndHumidityViaMqtt(); + publishHomeAssistantAutodiscovery(); + } + if (oldHaMqttDiscovery != haMqttDiscovery && haMqttDiscovery) { publishHomeAssistantAutodiscovery(); }