#Helper boolean, time changed

1 messages · Page 1 of 1 (latest)

slender tulip
#

I have created a Helper "toggle" to store a boolean value across automations. Essentially, one will cause it to be set and when it's set, it will impact the behavior of other automations one of which will eventually turn it off.

Is it possible to tell when it was it set to it's current value in a script or automation?

hazy iron
#

yes, you can pull out the last_changed value from the state object - however I don't think this will persist across restarts
{{states['your_entity_id']['last_changed']}}
Another way of doing it would be to have a button helper that you "press" every time you change the boolean value - that would store the time much more reliably in the state of the button

slender tulip
hazy iron
#

a toggle is off or on, a button just stores when it was last "pressed"

#

and yes you can activate the button within an automation