Hello,
I have this automation code, made via the visual editor (this is just a subset of the code, relating to a conditional action… however, why does it give me the big long not-very-user-friendly entity ID (Zigbee2MQTT)?
choose:
- conditions:
- condition: trigger
id:
- When front door is open
- Front gate open
sequence:
- type: turn_on
device_id: e62001bdb2bf822c05a78fd4e019a550
entity_id: b71b0a2594210526ffeda06eeb4801c4
domain: switch
- type: turn_on
device_id: 1a51c5e70e7d3a8efc2fca9d30197df7
entity_id: 923ef3901887e756ec6d0fdf56c1e0de
domain: switch
- delay:
hours: 0
minutes: 2
seconds: 0
- type: turn_off
device_id: e62001bdb2bf822c05a78fd4e019a550
entity_id: b71b0a2594210526ffeda06eeb4801c4
domain: switch
- type: turn_off
device_id: 1a51c5e70e7d3a8efc2fca9d30197df7
entity_id: 923ef3901887e756ec6d0fdf56c1e0de
domain: switch
There is no why that will do you any good. This is one (but not even all) of the reasons most people avoid device actions and use regular actions (previously called services) that rely on the entity_id and do not require the device id. These too can easily be made using the automation editor, they are just not listed as the top choice.
Personally, my most urgent reason to avoid device actions is that they are a pain when you replace a device with a new one. Then those ID’s you see will bite you hard. Even worse if the original device is gone and you have no idea what device was referenced here anymore (and neither does HA).
Yes, basically. The most obvious choice for most people is to start with the device and then think what thay want done with it. Home Assistant was originally designed to think about things you can do (actions, services) and then point to the things to want to apply that action to. The latter is less intuitive but more versatile. And in the end, the way that works best in HA. For instance, ot allows you to operate multiple things at once.
An example of such an action is light.turn_on. It allows to to use an entity_id as the target, or a multiple. But also a label that you added to multiple lights, or a room where all the lights are.