[Solved] Modifing group of light parameters (color_temp or rgb_color / brightness) without changing their state

Hi,

Is there a way to set parameters to an entity without modifying it’s state, through a scene or whatever else.

For example, I have zigbee bulbs/LEDs in bedrooms, kitchen, living room and WC that are grouped in light.all_rgbw_bulb. These bulbs can be as well switched on independently depending the occupancy of the room.

I created several scenes to provide a coherent color setting across all my bulb when they are on (white temp or rgb / brightness) :

- name: sc_light_white_concentration
  icon: mdi:bullseye
  entities:
    light.all_rgb_bulb:
      state: "on"
      brightness: 255
      color_temp: 230
- name: sc_light_red_night
  icon: mdi:television-box
  entities:
    light.all_rgb_bulb:
      state: "on"
      rgb_color: [255, 0, 0]
      brightness: 15
...

But the issue, if I try to setup parameters through the group mentioned above, I need to provide a state: 'on' statement that will unfortunately turn on all my bulbs, even those I don’t want to be on.

This is why I would like to run a scene without modify the state of the group to avoid to turn on the bulbs that are off, but only modify the parameters of those that are on.

Does someone have a solution to achieve that? or maybe with another approach…

Many thanks in advance.

1 Like

I succeed to “build” the needed entities with the following code :

- name: sc_light_white_concentration
  icon: mdi:bullseye
  entities: >
    {% set all_grp_lights_on = states.light | selectattr('entity_id','in',state_attr('light.all_rgb_bulb','entity_id'))| selectattr('state','eq','on') | map(attribute='entity_id') | list %}
    {% for single_light_on in all_grp_lights_on -%}
      {{ single_light_on }}:
      state: 'on'
      brightness: 255
      color_temp: 230
    {% endfor %}
- name: sc_light_red_lumineux
  icon: mdi:television-box
  entities: >
    {% set all_grp_lights_on = states.light | selectattr('entity_id','in',state_attr('light.all_rgb_bulb','entity_id'))| selectattr('state','eq','on') | map(attribute='entity_id') | list %}
    {% for single_light_on in all_grp_lights_on -%}
      {{ single_light_on }}:
      state: 'on'
      rgb_color: [255, 0, 0]
      brightness: 254
    {% endfor %}
...

but unfortunately, when I try to check the configuration (Configuration > Server Controls > Configuration validation > Check Configuration) I got the following error :

Invalid config for [scene]: expected dict for dictionary value @ data[‘states’][0][‘entities’]. Got None.

I’m probably missing a step…

1 Like

Finally I got it with another approach: using a script instead of a scene. It works then like a charm.

Please find below my working yaml script:

light_ambience_red_bright:
  alias: Light Ambience Red Bright
  sequence:
    - service: light.turn_on
      data_template:
        entity_id: >
          {{ states.light 
            | selectattr('entity_id','in',state_attr('light.all_rgb_bulb','entity_id'))
            | selectattr('state','eq','on') 
            | map(attribute='entity_id') 
            | list 
            | join(', ') 
          }}
        rgb_color: [255, 0, 0]
        brightness: 255

light_ambience_white_concentration:
  alias: Light Ambience White Concentration
  sequence:
    - service: light.turn_on
      data_template:
        entity_id: >
          {{ states.light 
            | selectattr('entity_id','in',state_attr('light.all_rgb_bulb','entity_id'))
            | selectattr('state','eq','on') 
            | map(attribute='entity_id') 
            | list 
            | join(', ') 
          }}
        color_temp: 230
        brightness: 255
...

Quickly, the idea behind that is to filter and built an entity list of my rgbw bulbs/LEDs that belong to my group and that have a state equal to on. Then by templating, I’m able to provide a formated list to be used in entity_id:

I realized when working on this automation that I’m still not sure to understand the real advantage of a scene compared to a script/automation … it seem to be so limited in terms of integration, that’s finally better to work with script/automation than scene.

1 Like