Skip to content

Commit

Permalink
feat(mqtt): publish overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
tspopp committed Dec 11, 2023
1 parent 0cb6b57 commit e901bdf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion AquaMQTT/src/task/MQTTTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,25 @@ void MQTTTask::updateStats()
mMQTTClient.publish(reinterpret_cast<char*>(mTopicBuffer), reinterpret_cast<char*>(mPayloadBuffer));


// TODO: implement active overrides here
auto overrides = HMIStateProxy::getInstance().getOverrides();
auto offset = sprintf(reinterpret_cast<char*>(mPayloadBuffer), "[");
if(overrides.operationMode){
offset += sprintf(reinterpret_cast<char*>(mPayloadBuffer) + offset, "\"%S\"", HMI_OPERATION_MODE);
if(overrides.waterTempTarget){
offset += sprintf(reinterpret_cast<char*>(mPayloadBuffer) + offset, ",");
}
}
if(overrides.waterTempTarget){
offset += sprintf(reinterpret_cast<char*>(mPayloadBuffer) + offset, "\"%S\"", HMI_HOT_WATER_TEMP_TARGET);
}
sprintf(reinterpret_cast<char*>(mPayloadBuffer) + offset, "]");
sprintf(reinterpret_cast<char*>(mTopicBuffer),
"%s%S%S%S",
config::mqttPrefix,
BASE_TOPIC,
STATS_SUBTOPIC,
STATS_ACTIVE_OVERRIDES);
mMQTTClient.publish(reinterpret_cast<char*>(mTopicBuffer), reinterpret_cast<char*>(mPayloadBuffer));
}
}
#pragma clang diagnostic pop
Expand Down

0 comments on commit e901bdf

Please sign in to comment.