From b7b8fc603d401d07fa9409bfdc228e7f4ba2726a Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Fri, 7 Feb 2025 08:21:05 +0100 Subject: [PATCH 1/9] add timer and expose: - duration - start/stop switch On start, it will display the remaining time instead of the watch --- include/devices.h | 20 ++++++++++++++++++++ include/display.h | 33 +++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/include/devices.h b/include/devices.h index 4f174d6..b6f8e0b 100644 --- a/include/devices.h +++ b/include/devices.h @@ -46,6 +46,24 @@ namespace Devices { strcmp("ON", msg) == 0 ? Display::changeHourFormat24(true) : Display::changeHourFormat24(false); } }).restoreStateFromCommand().build(); + Number* displayTimerMqtt = Builder::instance(new Number{ "Display imer", "display_timer", + [](const char* msg) { + auto value = String{ msg }.toInt(); + Display::Timer::timer = value; + displayTimerMqtt->updateState(value); + } + }).withMin(0).withMax(90).withStep(5).restoreStateFromCommand().build(); + Switch* timerMqtt = Builder::instance(new Switch{"Timer", "timer", + [](const char* msg) { + if (strcmp("ON", msg) == 0) { + Display::Timer::start(); + timerMqtt->updateState(true); + } else { + Display::Timer::stop(); + timerMqtt->updateState(false); + } + } + }).restoreStateFromCommand().build(); auto button = Builder