diff --git a/AquaMQTT/src/task/MQTTTask.cpp b/AquaMQTT/src/task/MQTTTask.cpp index 169ef50..6159085 100644 --- a/AquaMQTT/src/task/MQTTTask.cpp +++ b/AquaMQTT/src/task/MQTTTask.cpp @@ -1470,23 +1470,22 @@ void MQTTTask::publishFiltered( if (message->hasAttr(attribute)) { - float hotWaterTempRaw = message->getAttr(attribute); + float rawValue = message->getAttr(attribute); auto previousFilteredValue = mFilteredValue; - mFilteredValue = filter.updateEstimate(hotWaterTempRaw); + mFilteredValue = std::round(filter.updateEstimate(rawValue) * 10.0f) / 10.0f; if (fullUpdate) { publishFloat( MAIN_SUBTOPIC, topic, - config::MQTT_FILTER_TEMPERATURE_NOISE ? mFilteredValue : hotWaterTempRaw); + config::MQTT_FILTER_TEMPERATURE_NOISE ? mFilteredValue : rawValue); } else if (!config::MQTT_FILTER_TEMPERATURE_NOISE && message->hasChanged(attribute)) { - publishFloat(MAIN_SUBTOPIC, topic, hotWaterTempRaw); + publishFloat(MAIN_SUBTOPIC, topic, rawValue); } - // FIXME: this is broken - else if (config::MQTT_FILTER_TEMPERATURE_NOISE/* && (std::fabs(previousFilteredValue - mFilteredValue) >= 0.01)*/) + else if (config::MQTT_FILTER_TEMPERATURE_NOISE && previousFilteredValue != mFilteredValue) { publishFloat(MAIN_SUBTOPIC, topic, mFilteredValue); }