diff --git a/include/devices.h b/include/devices.h index 4f174d6..1bd3fe5 100644 --- a/include/devices.h +++ b/include/devices.h @@ -46,6 +46,26 @@ namespace Devices { strcmp("ON", msg) == 0 ? Display::changeHourFormat24(true) : Display::changeHourFormat24(false); } }).restoreStateFromCommand().build(); + Number* displayTimerMqtt = Builder::instance(new Number{ "Timer duration", "timer_duration", + [](const char* msg) { + auto value = String{ msg }.toInt(); + Display::Timer::timer = value; + displayTimerMqtt->updateState(value); + } + }).withMin(0).withMax(90).withStep(5).restoreStateFromCommand().build(); + Sensor* timerRemainingMqtt = Builder::instance(new Sensor("Timer remaining", "timer_remaining")) + .withUnitMeasure("min").withPrecision(0).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