I currently have an automation based on the current power being drawn from a plug. Once this power drops below a certain level for 2 minutes it triggers my automation.
When restarting HA this automation gets triggered after the 2 minutes as if it had never been triggered before, even though power draw is still below the treshold.
I have a number of other automations to make that will also get hit by this rule. How do i go about stopping them getting triggered when HA is restarted?
I’ve seen the initial_state variable, but even if i have it disabled for the trigger time it’s surely going to re-trigger once HA enables it again?
Now this was my first thought on how to do it, but couldn’t figure out how to track it’s previous state. Now i’m aware of trigger.from_state i’ll have a play and see if i can get it tracking, thanks.
Now this is what I originally though to do it with, but couldn’t figure out the logic for in HA. Having just tested it i’m surprised to see it hasn’t worked.
Based on HA code changes, the best way to accomplish is using the uptime integration and template conditions. The uptime integration was changed in 2020.12 from storing minutes to starting a static datetime, so you now need to create your own sensor or a template to get the minutes of uptime.
This code can be added as a template in conditions:
{{ as_timestamp(now()) - as_timestamp(states.sensor.uptime.last_changed) |
int > 120 }}
where 120 is how many seconds after restart you want to ignore triggers.
Here is a thread on Condition Uptime to see examples of the correct syntax and usage.