Include entity by id into a scene

Hello.
In the following snippet, two entities are part of the scene:

scene:
  - name: Romantic
    entities:
      light.tv_back_light: true
      light.ceiling:
        state: true
        xy_color: [0.33, 0.66]
        brightness: 200

Is it possible to include these entities NOT by name but by the id, in the same scene?

Thanks

Please format your code. Follow the directions in the blue ribbon. Click the link if it’s not working.

Also I’m not sure what exactly you are asking. You are using entity_ids, not names:

light.tv_back_light: true
light.ceiling:

tv_back_light is the name of the light component, not the ID.
If I set entity_id: tv_back_light, for the component, the scene doesn’t work.
If I set name: tv_back_light, it works…

I think you don’t understand entity id’s and their relationship in HA.

an entity id is made up from the object_id combined with the domain. If you have a light (aka the light domain) with an object_id of tv_back_light, the entity_id would be light.tv_back_light.

This has nothing to do with the name. The name is an attribute of the state object that is shown in the user interface for the user.

1 Like

You are missing the domain for the entity id.

This:

entity_id: tv_back_light

Should be

entity_id: light.tv_back_light

It definitely works, here’s one of mine:

- name: Hallway Night Light
  entities:
    light.lifx_hallway: # <---- an entity_id with friendly name 'Hallway Light'
      state: on
      brightness: 32
      color_name: red

Edit: actually your description and originally posted code dont match. You nearly had it right, the state was a little messed up for the first entity. Try this

scene:
  - name: Romantic
    entities:
      light.tv_back_light:
        state: true
      light.ceiling:
        state: true
        xy_color: [0.33, 0.66]
        brightness: 200

Edit 2: or maybe not. That actually seems valid from the example in the docs.

I set, for the scene:

scene:
  - name: "some scene"
    entities:
      light.light1:
        state: true
        effect: "Blink"

And for the light component:

light 1:
  - platform: mqtt
    schema: json
    object_id: "light1"
    name: "foobar"

And it doesn’t work. If I use the name (light.foobar) under “entities:” line it does work.

Look in your developer tools states menu (<> button lower left) for the actual entity id generated by that light config. it will be light.foobar

Ok, thanks.
Is there a way to generate an entity_id different than the name, for this component?

The entity_id will always be light.name

But you can change the friendly name using customize:

remove the space and number in light 1, yaml doesn’t work with spaces. Unless you are using packages. Are you using packages?

Also, object_id isn’t a valid attribute for MQTT lights. The object ID is pulled from the name you give it under the name attribute. So if you name it “Light 1”, it will create light_1 as the object_id. This name to object_id functionality does not work with all components by the way. Every component is different and it depends on the configuration for some. Some components create a default object_id that has no relation to the name.

light:
  - platform: mqtt
    schema: json
    name: "light1"

Thank you,

it works, but I wonder if is there a way to set this friendly_name on the light component, instead of the “customize” entry

Nope. https://www.home-assistant.io/components/light.mqtt/#configuration-variables