New to Zigbee2MQTT, how to create automations?

Hello,

Just switched from ZHA to Zigbee2MQTT in the hope my new human presence device will be more supported than what I had as far entities in ZHA
The first issue is that about 20 ZHA automations that I had are now completely wiped!
All pairings in Zigbee2MQTT went fine and devices are visible, but ie. motion sensor does not show under devices.
Am I missing something major here?

TIA!

1 Like

Just noticed under Developer tools > STATES old ZHA automations are shown?
More automation errors:

Home Assistant Core
Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: automation')
7:32:39 PM – (ERROR) setup.py
Unable to set up dependencies of default_config. Setup failed for dependencies: automation
7:32:39 PM – (ERROR) setup.py
Error during setup of component automation
7:32:38 PM – (ERROR) helpers/entity_registry.py
Automation with alias 'Turn OFF all lights downstairs' failed to setup triggers and has been disabled: Unknown device 'b8f2a01b7d6300e2f5143afcfb2e07f7'
7:32:38 PM – (ERROR) automation - message first occurred at 7:32:38 PM and shows up 4 times

When you have automations referencing device ID’s your whole automations are broken when one is not present anymore. Even only one deleted device can cause this sadly.

Device ID’s are randomized and even if you re-pair the same device in ZHA the ID changes. It is better to use status triggers that reference a friendly name instead of device ID to prevent this from happening in the future.

To fix this now you need to go into your automations.yaml manually and remove/change the references to the device ID’s.

Also have you given your Z2M devices a Friendly Name and also ticked the box to transfer the name to Home Assistant as well? Otherwise the Z2M devices have the Zigbee address as unique ID and name.

1 Like

Thank you for taking the time to reply!

Yes, I did give Z2M devices friendly names after I paired zigbee devices (which is too late with my issue) in Z2M because I read here that is the best approach (lesson learned).

Again, I appreciate your suggestion to remove/change the references to the device ID’s. At least it gives me a starting point!

I also came across this post by @francisp Automations won't start on Home Assistant Restart - #6 by francisp which gave me access to “Automations” back in HA. Unfortunately, it is empty but at least no nasty error :slight_smile: