diff --git a/include/mqtt.h b/include/mqtt.h index d99d3d7..cc11714 100644 --- a/include/mqtt.h +++ b/include/mqtt.h @@ -109,6 +109,10 @@ namespace Mqtt { if (client.connected()) publish(hourFormatMqtt->stateTopic, format24 ? "ON" : "OFF"); } + void publishLedState() { + Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON"); + } + void publishConfig() { for (Ha::Component* cmp : sensors) { publishComponentConfig(*cmp); diff --git a/src/esp_clock.cpp b/src/esp_clock.cpp index 88cd826..6f06008 100644 --- a/src/esp_clock.cpp +++ b/src/esp_clock.cpp @@ -25,7 +25,7 @@ Task tButton(TASK_IMMEDIATE, TASK_ONCE, []() { Display::displayTemp(Bmp::data.readTemp()); }, &ts); Task tLed(TASK_IMMEDIATE, TASK_ONCE, []() { - Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON"); + Mqtt::publishLedState(); }, &ts); void setup() {