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.
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?
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
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…
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.
I have now found the cause for the original problem, I stated above that the entity_id changed when rebooting home assistant.
I had a custom_component that wrongfully set a BinarySensordevice_class to BinarySensorDeviceClass and not BinarySensorDeviceClass.POWER . This made the function as_storage_fragment() in file entity_registry.py to crash (yes there was a log to that in the home assistant logs, but I never understood why an Enum cannot be converted to JSON). Anyway, this prevented the writing of all entity_id’s to the .state/core.entity_registry and in effect all renames I did were reverted to the default value upon reboot of home assistant.
I’m so happy now that I found this, I have no clue if this would help anyone else, but I put it here.