From 16befa50e5bf23839a48774de355c473e683a14d Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Fri, 28 Feb 2025 14:11:22 +0100 Subject: [PATCH] allow changing timer while it is on --- include/devices.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/devices.h b/include/devices.h index 966be05..1b32d0a 100644 --- a/include/devices.h +++ b/include/devices.h @@ -51,6 +51,10 @@ namespace Devices { auto value = String{ msg }.toInt(); timer = value; displayTimerMqtt->updateState(value); + if (Display::tTimer.isEnabled()) { + Display::tTimer.cancel(); + Display::tTimer.enable(); + } } }).withMin(0).withMax(90).withStep(5).restoreStateFromCommand().build(); Sensor* timerRemainingMqtt = Builder::instance(new Sensor("Timer remaining", "timer_remaining")) @@ -61,7 +65,7 @@ namespace Devices { Display::tTimer.restart(); timerMqtt->updateState(true); } else { - Display::tTimer.disable(); + Display::tTimer.cancel(); timerMqtt->updateState(false); } }