From e901bdf4cc765041cef57d865fa53d0da60cc917 Mon Sep 17 00:00:00 2001 From: Thomas Popp Date: Mon, 11 Dec 2023 21:39:33 +0100 Subject: [PATCH] feat(mqtt): publish overrides --- AquaMQTT/src/task/MQTTTask.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/AquaMQTT/src/task/MQTTTask.cpp b/AquaMQTT/src/task/MQTTTask.cpp index 65c3812..3803396 100644 --- a/AquaMQTT/src/task/MQTTTask.cpp +++ b/AquaMQTT/src/task/MQTTTask.cpp @@ -375,7 +375,25 @@ void MQTTTask::updateStats() mMQTTClient.publish(reinterpret_cast(mTopicBuffer), reinterpret_cast(mPayloadBuffer)); - // TODO: implement active overrides here + auto overrides = HMIStateProxy::getInstance().getOverrides(); + auto offset = sprintf(reinterpret_cast(mPayloadBuffer), "["); + if(overrides.operationMode){ + offset += sprintf(reinterpret_cast(mPayloadBuffer) + offset, "\"%S\"", HMI_OPERATION_MODE); + if(overrides.waterTempTarget){ + offset += sprintf(reinterpret_cast(mPayloadBuffer) + offset, ","); + } + } + if(overrides.waterTempTarget){ + offset += sprintf(reinterpret_cast(mPayloadBuffer) + offset, "\"%S\"", HMI_HOT_WATER_TEMP_TARGET); + } + sprintf(reinterpret_cast(mPayloadBuffer) + offset, "]"); + sprintf(reinterpret_cast(mTopicBuffer), + "%s%S%S%S", + config::mqttPrefix, + BASE_TOPIC, + STATS_SUBTOPIC, + STATS_ACTIVE_OVERRIDES); + mMQTTClient.publish(reinterpret_cast(mTopicBuffer), reinterpret_cast(mPayloadBuffer)); } } #pragma clang diagnostic pop