A restart changes entity_id so Automations fail to set up

I’m running Home Assistant Core 2024.10.1 and have had this issue for some months now. When I restart Home Assistant some Devices change their entity_id. This has the effect that Automations fail to set up.

If I click the link and “correct” the Automation and save, automations.yaml changes to a new entity_id:


at this point the automations work as expected until I restart Home Assistant.

This happens on 5 of my 117 Automations and it is mainly ZHA devices but not only (nissanConnect above), and it is only happening on devices that I’ve added recently. I cannot find anything related in the main log. Could it be some kind of db issue, from deleting a device or similar?

Or is there any debug/log/configuration where I can see more what entity_id the devices have or similar?

Thanks in advance

Do these entities have actual entity IDs, like climate.something?

If so, use an entity action instead:

- action: climate.set_hvac_mode
  target:
    entity_id: climate.whatever
  data:
    hvac_mode: heat_cool

It was a bit tricky to find the actual entities, and then replace them directly in automation.yaml (I usually don’t edit this file by hand) but yes it worked!

It now looks like this
image

It would be nice to know why this doesn’t work with the web interface on these particular devices, it worked perfectly well on others…

As I said, try an entity-based action (from Climate on the first selection box) rather than a device-based one:

Ah sorry now I understand, yes that works as well (and then you dont have to edit the automations.yaml directly).

If adding an entity-based action the actual name of the entity is used in automations.yaml and not the entity hash.

I checked in the .storage/core.entity_registry and found that my older ZHA devices have entries in there, and my newer ones don’t. That is why the device-based action works on some but not all devices. Then I’m curious, why do my newly added devices not add entries in the core.entity_registry?

But as you say, sticking to entity-based actions works.

Thanks

Hi edse,

Followup info for you.
Why and how to avoid device_ids in automations and scripts.

2 Likes