I have an automation setup via mqtt that sends me a pushbullet alert if my Sonoff S31 gets unplugged or loses connection to my HA server. What I want to do is add a condition that will wait 1hr of being in a disconnected state before sending me a message. This helps prevent false-positives from random wifi disconnects, etc. I THINK this needs to be accomplished using a template trigger, but I’m not very good at template building. My device entity is switch.deep_freeze. I’m also using the automation wizard built into HA ( I know that’s a sin here bu it’s SO easy )
In your automation trigger, there might be built in time attribute to use. If not, you can add a script that you can turn on and off.
What is the trigger in your automation?
The trigger I’m using is a MQTT LWT state of “offline”.
just use the following as an example:
alias: Notify if entry light unavailable
initial_state: 'on'
trigger:
- platform: state
entity_id: light.front_door_light
to: 'unavailable'
for:
seconds: 18
action:
- service: notify.Pushbullet
data:
message: 'The front door light has gone unavailable'
the for:
part is what you need.
I’m using the automation wizard built into HA so I’m not sure how the “for” fits into that format. I actually tried adding “for” to my automation.yaml file but the old format doesn’t work.
I don’t use the automation editor as its officially rubbish, and I’m guessing doesn’t have the for:
function built into it.
You can use a combination of the old ‘manual’ automations with the automation editor by using this:
configuration.yaml
automation old: !include_dir_list automations
automation: !include automation.yaml
then create a folder under config called ‘automations’ and keep each individual automation as a separate yaml file within this folder. Its much neater and easier to work with.
can I name these new automation files anything I want?
Yes, as long as they comply with the normal yaml rules:
Lower case
No spaces, only underscores to separate words
No numbers or special characters