Automations fail to load after HA restart

Hi,
I have 3 automations that are responsible for switching on and off a lightswitch (socket). Two of them when the camera detects motion, one to automatically switch off after a few minutes.

After a restart of HA sometimes some of these automations fail to load with a message the device is unknown. Sometimes all of them, sometimes just one or two.

My currect solution is to rename the automation and save it again. It will now work fine until the next HA restart.
It seems the device (the switch) is just not ready when the automations are loaded, failing to load the automation.

Is there a way to fix this? For instance: Delay loading the automations a few seconds?

Thanks,

Hi, welcome to the forum!

How are those devices integrated in HA?

Don’t use device ids in your automations.

If you use entity_id instead of device_id then your automations won’t be disabled when the devices are missing temporarily after a restart. It has other advantages to. As explained here: Why and how to avoid device_ids in automations and scripts

1 Like

Thanks,
I have to apologize first!
I feel a lillte bit stupid now. :grin:

I had read that documentation of using entities instead of devices but for some reason I did not think it would apply to my setup.
Everything was working fine :wink: (except the startup)

I now changed both detectors and switches to the entities and after several HA restarts (including full reboot of the server) everything is loading fine.

It took some time to really understand what I need to do, but the explanations on the link you gave me are really great. You (me) just need to read it!

In the future I will read documentation better!

1 Like