Very recently, with the last two updates to HA Core, I have three (out of many, many) automations that trigger when HA comes back online. I have looked at the yaml code for the three problem automations and compared to the other automations, I see no difference. One is within the MQTT area, the other is an announcement from Alexa, and the other is ratgdo garage door controller.
All automations are developed via the UI.
Any insight into why this is happening and how to correct these three automations would be helpfull.
Are you using “device triggers”? They work in a nonsense way that triggers even when going from “unavailable”. That means trigger “when door opens” does not only trigger when door contact goes from off to on, but also on HA restart - it goes from unavailable to on - while the door obviously didn’t magically move and just remained open the whole time. If that’s the case, I’d suggest to switch to “state trigger” and specify the change from off to on…
@armedad and @tomas1 I should mention both of the codes posted use a Smartthing multi-function sensor. the ragdo obviously does not - yet it behaves the same.
yet I have many of these Smartthing multi-function sensors around the house and only these two act this way.
follow what @Stiltjack said… this will help you, and also help us help you.
if you’re looking to understand what is triggering these on restart, go restart it, then after it’s triggered, look at the trace or logbook and see the states of the entities as they get triggered.
to give you the cliff notes version of the document:
don’t use device_id and entity_id with the big long hairy numbers/letters.
instead of that, use entity_id with human readable names. like sensor.drawer_closed.
you can try to read a book on yaml, but my advice is not to do that, but instead to use the UI to build out your logic, then switch it to yaml mode and read the yaml… make sure you understand what home assistant just generated for you.
then as you’re doing point things that you can’t figure out how to do in the ui, use a search engine and ask… most of the time, someone else has asked that same question and it’s already been answered here somehere with sample code…
It states, for the clothes dryer automation, it showed the sensor not moving, then unknown, then not moving.
I also checked some other sensors (smartthings multi-function and others) that are to send me notifications and they showed the same behaviors, but did not alter me.
The behavior being in a known state (HA running) to unknow (HA Rebooting), then back to a known state HA running).
alias: Clothes Dryer Stopped Notification Everywhere In The House.
description: ""
trigger:
- platform: state
entity_id: binary_sensor.your_clothes_dryer
from: 'on'
to: 'off'
for:
minutes: 1
condition: []
action:
- service: notify.alexa_media_living_room_echo_spot
data:
message: OK, the clothes dryer stopped. Time to fold the clothes.
data:
type: tts
mode: single
Why do it like that? Because if on startup the binary_sensor’s initial state is momentarily unavailable (or unknown) and then becomes off, that state-change is sufficient for a Device Trigger to detect as a change to off.
Don’t forget to change the entity_ids of the binary_sensors in my examples to match the ones in your system.
Short version: At a novice but growing level - Understand entity vice device. Understand entity numeric and state features.
Appreciate both @armedad and @123 as you helped me walk through setting up the automations, but also enlightened me to factoring in error handling along with the state of the system/components on a restart/reboot.
Corrected the ratgdo door sensor, Dryer, and File cabinet automations as @123 suggested. And while using the UI, also stopped and examined the yaml code as @armedad suggested - very helpful.
In yaml code I am definitely in the crawl, walk, run stages…that would be very much crawling right now.
Also bottom line - those strange and seemingly random (odd that only three sensors acted this way - I suppose a feature somehow - but - I learned!) notifications have been corrected - thank you.
Again, many thanks to all - for me, you each gave a part of the solution that helped me better understand, and make better code in the future.