Use current value of timer in a calculation to reset a countdown

I have an action (say switch light off) that is invoked in two different flows, each of them using a timer (I know Homey has several; any would do). The timer will have a different value, accoding to which flow has occurred (e.g. passing through a space 10 sec vs doing something in a space 100 sec then check whether the action is finished).

When a flow runs I want to set the timer to the greater of

  • the timer appropriate to that flow
  • the timer currently running (if any)

That is because I want to avoid the simplistic approach of always resetting the timer to the longer time, which may be unacceptable when only a brief period is actually needed.

Real-life situations occur in which the short-timed flow is triggered in the middle of a period during which the long-timed timer is working. If I do not want the short-timed flow to override the running flow (switch the lights off prematurely) the only option seems to be to reset the timer to the full longer period (meaning that is may in fact not reach zero until almost twice the time intended)…

BUT BETTER simply reset the timer to

max(current value of timer, desired timer value)

There is so much comment about the timers in the various Countdown threads that I may have just missed it, but I cannot find a way to easily insert a variable for the current value of a timer into an arithmetical calculation that would specify the new value for the timer. Apologies if it has already been explained.

Throughout my system such issues arise regularly and I would like this facility to be consistent and preferably brief and easily inserted in each additional flow that controls a device (there may be many more than two flows for any one device).

If you use Chronograph then you can easily get the current value of a timer.
You can then use it in an expression

When you use Countdown, then there is a variable available that holds the current value:


You didn’t specefy what triggers a short timer and what a long timer, so I’m using two buttons.

The first button checks whether the long timer is running, of not start short timer.

The second button starts the long timer and stops the short timer

If either timer is started: light on

If either timer ends: light off.