publish led state at startup

This commit is contained in:
Nicu Hodos 2023-07-12 19:02:39 +02:00
parent 22544c225a
commit f1d41ade51
2 changed files with 5 additions and 1 deletions

View File

@ -109,6 +109,10 @@ namespace Mqtt {
if (client.connected()) publish(hourFormatMqtt->stateTopic, format24 ? "ON" : "OFF"); if (client.connected()) publish(hourFormatMqtt->stateTopic, format24 ? "ON" : "OFF");
} }
void publishLedState() {
Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON");
}
void publishConfig() { void publishConfig() {
for (Ha::Component* cmp : sensors) { for (Ha::Component* cmp : sensors) {
publishComponentConfig(*cmp); publishComponentConfig(*cmp);

View File

@ -25,7 +25,7 @@ Task tButton(TASK_IMMEDIATE, TASK_ONCE, []() {
Display::displayTemp(Bmp::data.readTemp()); Display::displayTemp(Bmp::data.readTemp());
}, &ts); }, &ts);
Task tLed(TASK_IMMEDIATE, TASK_ONCE, []() { Task tLed(TASK_IMMEDIATE, TASK_ONCE, []() {
Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON"); Mqtt::publishLedState();
}, &ts); }, &ts);
void setup() { void setup() {