(solved) Timer question (rules)


I have a Alarmclock, and I want to trigger different things after some time (turn coffe machine on, and 30min later turn it off), but I am unsure about how timers specificially work.

sendCommand(coffee, ON) sendCommand(lichtwecker, 10) timer1 = createTimer(now.plusMinutes(5), [| sendCommand(lichtwecker, 40) timer10 = null ]) timer2 = createTimer(now.plusMinutes(30), [| sendCommand(coffee, OFF) sendCommand(lichtwecker, OFF) timer30 = null ])

Timer10 ist triggered 5 minutes after the coffee machine is turned on. Is timer30 initialized AFTER timer10 finnished (is timer10 blocking?) or is it initialized at the same time.
coffee ON = 0
timer10 = +10min
timer30 = +30 or +35min?


EDIT: to answer the question for anyone that comes looking, the timer are initialized at the same time.
So timer10 would be after 5 minutes in th above example (now.plusMinutes(5)), and timer30 would be after 30 minutes.

A different approach would include the Expire Binding:

Switch coffee "Coffee Machine" { expire="30m,command=OFF", <your other binding(s)...> }
Dimmer lichtwecker "Licht Wecker" { expire="5m,command=40", <your other binding(s)...> }

So your rules won’t have to use timers for those items that should always return to a specific state, or have a specific command sent to them, for some period of time when they are in a different state or after which they have received a different command.

1 Like

Is there any way to change the timeout value for the expire?

Use case: My daughter has a habit of turning on lights, even when they are not needed. 95% of the time, if it is between dawn and dusk, if the lights are on, we want them off after 5m. However, in the evening and early morning, we would want them to expire after 30m.

Is this possible?

I don’t think the Expire binding can handle logic at the item level.

You would need a rule to handle that case instead, probably using a Timer.