Use names in automations/scripts for device/entity ID

I had for some reason dead Z-Wave nodes which I had to restore to the system. I just removed the dead and added them again and gave them the same name. My dashboard just continued to work because the newly added devices had the same name (id).

Unfortunately this didn’t applied to automations and scripts because they use (not always) a numeric ID which had changed with the new devices. It was a cumbersome action to fix this.

If automations/scripts also uses for device_id and entity_id the name and not the unique ID number it would be much easier to replace a failed node (either Z-Wave or any other).

My suggestion is to fix this in the Automation/Script builder to use names and not numbers.

- type: turn_on
            device_id: 8b4544f2daf3ce4c505008c66902456a
            entity_id: switch.lamp_badkamer
            domain: switch
          - type: turn_on
            device_id: 0172666d6b671de889d35447df7072be
            entity_id: switch.bedlamp
            domain: switch
          - type: turn_on
            device_id: 7941784e124455202fc66c09e80c4718
            entity_id: a047ae31505e7ee4aba0c5f9f1045306
            domain: light

Don’t use device ids.

2 Likes

Beat me by 10 seconds… Totally agree with that.

You are looking for entity based stuff not device based stuff for that.

This is not a feature request, it already exists.

2 Likes

I agree with avoiding device ids, but entity ids are no longer used in the UI either. They use a unique identifier now. I’m sure it was introduced to fix something but it has made helping people and replacing entities so much more difficult. So this FR should exist.

I just built this in the ui, so not sure what you mean.

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - automation.aaasfgdfafdasfgdafgdaris_it_raining
    from: "on"
condition: []
action:
  - service: light.toggle
    target:
      entity_id: light.b_porch_socket
    data: {}

Do yu mean trying to recover once there is a situation like this is hard because of the unique_id?

Have you not seen this all over the forums:

trigger:
  - platform: device
    device_id: 443600d819fcb00320d873c671750bde
    domain: climate
    entity_id: 16bad75e1fdde8427cbaad40827ba603 #### <----- not an entity id
    type: current_temperature_changed

That shouldn’t be called an entity_id, as it is only valid as it relates to that device_id.
I don’t think it has to be unique in HA, just unique under that device_id.

I don’t even think of that an an entity_id really.Should be called unit or sub-device or something.

Entity_id’s are what I show above, not related to device_id except in a databse in HA somewhere. IMO.

Hang on…

So things like binary_sensor.dayime are no longer entity ids then? They’re still called that in my UI. :worried:

I believe it only happens for device triggers/conditions/actions.

Um…

And this a different thing from the unique id you have to give a template sensor if you want it to appear in the UI?

I have no idea what it is for or how it is generated. I do know it makes replacing entities harder.

It’ll end in tears, you mark my words… :unamused:

The tears are already flowing…

I’ve seen that weird “entity_id” reference as well. I have no idea how this is not supposed to be totally confusing to new users.

Giving it a different name should be something that I would think the core team would want. So confusing now.
It’s like the users are caught over infighting between device_id trigger people and entity_id trigger people on the core team. More is not always better.

It’s the config entry id.

When you use the UI, you get all the UI stuff. That way, if you change the entity_id, it doesn’t matter for your trigger, action, or condition.

This FR is basically requesting to undo all the work that was put in place to make it so people didn’t need to update automations when they change device names and entity_ids. FYI this was a long standing WTH and a major pain point for beginners.

This FR should really ask for a way to substitute a device with a new device, otherwise I never see it happening.

1 Like

I know I’m drifting from the original question to this side naming conflict.

Already opened that one three years ago.

1 Like