I noticed recently (not sure how recent) that automations I create for devices now use a cryptic entity_id instead of the more human readable one that shows up when looking at an entity from a device page.
For example, in an automation controlling this device:
While the device in the above code has an entity_id of switch.family_room_bookshelf_sonoff_on_off which is more readable. I can’t find the long string above anywhere in the device page for reference.
Not a direct solution for the problem. But I always avoid using the devices and use only the entities. Many advantages with this. And reason against doing it as well?
So instead of starting with device, start with call service, use switch.turn_on and then the entity. Done.
This is then still working with a replaced device, if you give the new entity the name of the old.
Actually, I almost always start with the visual editor since it’s generally a quick and easy way to get an automation started (for me at least). So I don’t pick device or entity IDs, I pick devices by name from a drop down list in the visual editor. The resulting code is what has the device_id (which I know is always a long string) and the entity_id - which is now a cryptic string instead of the human readable text as shown in the device editor page.
That’s what my question is based on – why is it different know. When I add a new device to an existing automation, I see the older yaml code that references the entity_ids of devices by their human readable string. The newly added devices to the automation use the string instead.
I guess I’ll try modifying the automations by hand to replace the string with the human readable string to see if they still work. If that works then I’ll call it done and just an annoyance of something extra I have to do when editing an automation these days.
Or - in a general statement - I wish there was a way to insert # comments in an automation so I can just simply add a comment to a section saying what the device is. But comments seem to disappear when I save so it’s not possible (as far as the last time I checked).
But my post is not in reference to triggers, it’s in the action items where I control a device. I totally agree with the use of states in triggers but that’s not what I’m referencing here in this post.
No. He and I are refering to the actions as well. It is an exact part in his quote, if you read it.
Actually, I almost always start with the visual editor since it’s generally a quick and easy way to get an automation started (for me at least). So I don’t pick device or entity IDs, I pick devices by name from a drop down list in the visual editor.
Can you please post a screenshot what are you meaning? Perhaps we can explain than better, what is unclear in our answers.
I did notice something, however, this particular device is zigbee and controlled via zigbee2mqtt but I can’t seem to find that entity ID anywhere on the Zigbee2Mqtt dashboard either for the device.
Yes. Exactly. And instead selection “Device” here, select “Call service”. Same dropdown, same UI.
Then a fitting service. e.g. switch.turn_on. Or the generic homeassistant.turn_on. And then select the entity.
More or less no change and not more to select. But better in many ways.
In both way, you need to do what (on) and which (device/entity), so instead of starting with the which and then selecting the what, start with the what and then select the which.
Thank you for the clarification, I’ll update my process.
Oh side note – and this will be super helpful to me… can I list multiple entities here? I think I would be able to… that will make things a lot cleaner for me.
Beside the example from finity as answer, you can always just do it in UI. There just select more entities from the picker, service call options, … And then switch to yaml and see what magic happened and what is the syntax for it.