#Device or entity?
1 messages · Page 1 of 1 (latest)
entities, once you'd have to replace the device, you can easily rename the new device with the same name used for previous one. That way you dont have to alter automations etc.
If this answers your question you may mark your thread as resolved by checking the RESOLVED box 😉
I wasn't aware, thanks a lot!
np
I have been thinking about it... If I'd have to replace a device and I rename it with the same name, why would I need to change anything in the automations if I was using the device name instead of entity id?
because device_id will change and break the rest.
do a google search for pros and cons
I see... I had a look at my yaml code in one of my automations:
- action: cover.open_cover
metadata: {}
data: {}
target:
device_id: 74c46eab383f9090f74ca45aabe7176e
That device_id corresponds to a device I named as Suite Persiana, and I would have expected that the device_id in the automation was something like suite_persiana, but that is not the case
I understand now, thanks!
If your question feels answered, you may mark this thread as resolved by clicking the RESOLVED box 😉
Also see this post for more information
https://community.home-assistant.io/t/why-and-how-to-avoid-device-ids-in-automations-and-scripts/605517
Background When you start writing automations, a device trigger seems the obvious choice. Everybody knows what a device is and it comes at the top of the UI dropdown list. It works… but it is certainly not a “great way to start” because it is storing up problems for the future. Far better to use an entity, with state or numeric_state....
Entities are more “portable” and should be preferred. They are also easier to work with from a YAML pov. The only case I’m user of is device triggers for things like buttons. Haven’t yet figured out how to make those work with entities.
same here, buttons are only devices that I use in automations
Guess you are using Zigbee buttons and ZHA then?
Yup. Bit of a limitation of ZHA if other button providers don’t suffer that.