UM SHT: MQTT re-publish values on unit change

This commit is contained in:
ezcGman 2022-12-19 22:30:11 +01:00
parent ea6d339b9c
commit f3d52f4932

View File

@ -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();
}