Assign an entity_id to a group


I have created a group in my YAML configuration:

  - platform: group
    unique_id: livingroom_cask
    name: "Cask"
      - light.livingroom_cask_top
      - light.livingroom_cask_middle
      - light.livingroom_cask_bottom

The set unique_id seems to be useless, no clue where it gets used.
I’m wondering whether there is a way to assign a entity_id to a group. Currently, HA transforms the name Cask and creates an entity with the name light.cask. I’m actually able to give an entity_id to the entity in the UI Settings -> Devices & Services -> Entities. But next to the fact, that I want to control everything in my configuration files, the entity_id is reset after a while and appears again as light.cask. The old entity is still listed but with this red exclamation mark with a state of unknown. I guess a simple restart or reload of groups resets the entity_id again.

no clue where it gets used

It’s stored in the (hidden) entity registry and serves as a ‘unique identifier’ to reference the light entity you have defined.

The entity’s entity_id is (as you have discovered empirically) derived from the name option. It converts the value of name into what is called a ‘slug’ (all lowercase and limited to a small set of ASCII characters; spaces replaced by underscores).

You have configured a light entity in YAML so that serves as its reference. Every time you restart, the entity is created based on its YAML configuration.

FWIW, if you create a Light Group entity via the UI ( Settings > Devices > Helpers > Create Helper > Group > Light Group), it behaves the same way and uses whatever you enter in the ‘Name’ field to create a slug for the entity_id. It also creates a unique_id but it’s not shown in the UI (it’s recorded in the entity registry).


Ironically, it’s used when a user wants to break the link between entity name and entity ID. to use an entity ID other than domain.slugify(name)…

That’s why the UI won’t let you edit the details of an entity that doesn’t have a unique ID but it also doesn’t show up in the UI itself.

1 Like