If you want to rename the device and all the entities below are modified, then you have to go to all the automation to modifying those.
Using device_id will not be impacted by this. There are some pro and cons.
That was helpful, for me at least, in understanding how that works.
And in turn it has me appreciate the Watchman integration even more, and thought the integration deserved a mention in for those even greener than I am with HA, in this regard.
Also there other benefits to use device_id as this will be used by HA in some parts of the code like in logbook apparently (I’m just repeating info that I got from the forum).
When you onboard a new device you should first give it a sensible name. If you’re renaming after you’ve started using it, that’s a different matter, but you likely will only have to do the search and replace once ever (assuming it gets a proper name the second time around). If you replace a device you will have to rename the usages every time you replace a device, as opposed to renaming device entities.
Renaming entities is a choice, if you do not, automations will work, if you do change them, it is exactly the same amount of work as changing device IDs.
The biggest dealbreakers using device ids for me are:
I had integrations suddenly changing all device id’s, breaking all automations. Then there’s no help what changed to what, because old id’s no longer exist. Automations using entity ids did not break.
If a device breaks that is used in a trigger, the whole automation is disabled, even if there are more triggers that could have still worked perfectly. Entities don’t have that problem.
Device conditions/triggers are hard to get support on from others here, because the behavior and actions are specific to the device.
When a device breaks or is replaced by something else: entity - no problem, with device ids: always needs fixing everywhere. It is not even a given that just search/replace the device id will work across different brands/integrations.
I can test state like this, but that only triggers on the attribute changing – yes, it will trigger if I first press the button 2x times to set KeyPressed2x, but if it is already KeyPressed it won’t trigger since it’s not changing.
trigger:
- platform: state
entity_id:
- event.recirc_pump_remote_switch_scene_002
attribute: event_type
to: KeyPressed
I tried using an event trigger like this, but it’s not triggering. Plus, I’m wondering if triggering on such a frequent event is a bad idea.
The most usual reason for me to change a name is that I am repurposing the device, so I actually find it useful that it breaks stuff noticeably when I rename - as of course I need to edit those to accept the replacement device. I tried leaving the entity names as they were but I find it impossible to recognise which one to use unless they bear the name of their parent device - as it has become.
I think this post should not be pinned. It’s a good post, but not important enough for all users to follow.
Disclaimer: I’m not saying anything in the guide is wrong (since the author obviously knows his stuff). I’m only challenging the relevance. Maybe this discussion will lead to firther improvements to the article or at worst, I learn that my assumptions are wring. I’ll take a bit of an oppositie opinion here and there with the expectation to end up in the middle.
Why this post should not be pinned (opinions)
I think beginning users should use devices more often. This posts scares them down a more difficult path.
The guide hides other pinned posts from the front page which are more relevant to a larger number of users.
It deserves a prominent place in the cook book, but it’s not the first thing every users should read.
Let’s go through the arguments:
The yaml will be longer and harder to follow…
This is only relevant if you use yaml primarily. For UI users, using a device is often easier to use and follow.
Looking at the majority of users, +1 for “using devices”.
If you replace a device you will have to go through every automation it appears in…
True, but the same can be said in favor of devices to avoid updating when renaming an entity (which I do more often than replacing devices)
I can’t say which scenario is more common in general, so let’s call it a tie.
Automations using device_id report as unavailable if they depend on missing devices.
This could be an important argument, but the impact is not explained. Will the automation not work?
It’s inconclusive for now, but could be a + for “not using devices”.
Using entity states you can exclude “unavailable” and “unknown” from your triggers:
This is a good suggestion to make automations more robust, but how many people actually use it? Beginners should know when to use it, but in a lot of cases, it won’t be relevant.
+1 for knowing “when to use devices and when to use entities”.
Device actions, triggers and conditions do not support more advanced features like templating.
As.abive, it’s not a reason not to use devices, but it might be a reason to know “when to use devices and when to use entities”.
To summarize:
Devices are great, especially for beginners
Entities are great for advanced users
The way the article is currently positioned, it discourages beginning users from using devices. It would be better to change some of the working to emphasis when to use entities instead of devices and targeting the moderate users through a prominent place in the cookbook instead of the top pinned article in community guides.
You need to consider the other side of the coin too: Reading YAML and helping people using device IDs are harder — and I say this as an experienced user.
“Help us help you.”
It really isn’t that hard to grasp the concept of entities being the core concept and that devices are basically a grouping of entities.
It’s such a foundational cencept that it is unlikely to change ever, I think. It’s better to make the shift earlier before having to rewrite lots of things later.
Almost all of the problems I’ve had with automations has stemmed from using devices early on in my HASS experience. Things stopped working without any notification. All because I changed batteries on a few sensors and the new devices (obviously) got new device_ids.
Perhaps an issue with the specific integration creating new device IDs?
Either way, this is a real problem when people do replace devices, say a blown smart bulb with a new one: It will be a new device, compared to just renaming and entity and you’re done.
This is all fine and good, until you use Zigbee switches (buttons, not relays) in ZHA. They don’t have entities except battery etc. So you are stuck on using event triggers and you have the choice of either device_id, unique_id or device_ieee.
That type of issue will likely be addressed by the use of event entities if/when they get added into ZHA. Like a lot of new features in HA, it was discussed and implemented; but it takes time and resources to add those features to each of the 2000+ core integrations as needed.
IIRC, ZHA has already been undergoing some significant updates, so it likely the case that those are taking priority over adding event entities.