alarm clock based on input_datetime #547
-
I am trying to make a light to switch on based on the time stored in a input_datetime helper. I came up with below code, but it never triggers at the time in the input_datetime helper.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
First, have you confirmed the string The main problem is that the |
Beta Was this translation helpful? Give feedback.
First, have you confirmed the string
f"once({input_datetime.alarm_time})"
produces a correctly formatted time?The main problem is that the
alarm()
function is destroyed as soon asupdate_alarm()
returns, since there is no longer any reference to it in any scope, so there will no longer be any trigger. See the docs. You need to keep some reference to the closure function so it remains defined after the enclosing function returns, eg, by setting a global variable.