Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95925

Automation state trigger with condition on time spent in previous state

$
0
0

@SteveDinn wrote:

I just want to make sure I’m thinking about this correctly. I want to have an automation run if I turn off a light, but only if it had been previously on for more than 30 seconds. So a quick flip would NOT trigger the automation. Am I correct in thinking that I can do this:

   {{ (now() | as _timestamp) - (trigger.from_state.last_changed | as_timestamp) > 30 }}

Will the from_state contain the length of time that it remained in the previous state? I’m assuming that since the trigger fired, that now() is the time of the state change.

Posts: 18

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 95925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>