Blueprint can not use group of devices?

I am trying to use blueprint (xiaomi button) to turn on/off a group of lights and it appears that I can only call upon device by device, and I can not access predefined group of devices?

(I have tried both; group of devices defined within home assistant, as well as a device group as defined within ZHA/zigbee).

Is there a reason for that?

It’s definitely possible to call a service for a group, but you’ll need to use another service than light.turn_on.

When you group lights in zigbee, it will appear in HA as a new light.xxx entity, so I don’t understand how this did not work for you to turn it on/off from the blueprint.

Please show your code.

this is the code I am using (blueprint found on this forum), it does not recognize/offer light groups:

blueprint:
name: ZHA - Mijia Wireless Remote Switch (WXKG01LM)
description: Automate your Xiaomi Mijia Wireless Round Remote Switch using ZHA events.
domain: automation
input:
mijia_round_switch:
name: Mijia Wireless Round Switch
description: Mijia Wireless Round Switch to use
selector:
device:
integration: zha
manufacturer: LUMI
model: lumi.sensor_switch
remote_button_short_press:
name: Single Press
description: Action to run on single press
default: []
selector:
action: {}
remote_button_hold_press:
name: Hold
description: Action to run on hold
default: []
selector:
action: {}
holdtime:
name: Time interval for hold detection, in seconds
description: Time to wait until hold_press is activated
default: 1
selector:
number:
min: 0.0
max: 10.0
unit_of_measurement: seconds
step: 1.0
mode: slider
remote_button_double_press:
name: Double Press
description: Action to run on double press
default: []
selector:
action: {}
remote_button_triple_press:
name: Triple Press
description: Action to run on triple press
default: []
selector:
action: {}
remote_button_quadruple_press:
name: Quadruple Press
description: Action to run on quadruple press
default: []
selector:
action: {}
remote_button_multiple_press:
name: Multiple Press
description: Action to run on multiple press
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger:

  • platform: event
    event_type: zha_event
    event_data:
    device_id: !input ‘mijia_round_switch’
    action:
  • variables:
    click_type: ‘{{ trigger.event.data.args.click_type }}’
    attrname: ‘{{ trigger.event.data.args.attribute_name }}’
    value: ‘{{ trigger.event.data.args.value }}’
    command: ‘{{ trigger.event.data.command }}’
  • choose:
    • conditions:
      • ‘{{ attrname == ‘‘on_off’’ }}’
      • ‘{{ value == true }}’
        sequence:
      • wait_for_trigger:
        • platform: event
          event_type: zha_event
          event_data:
          device_id: !input ‘mijia_round_switch’
          command: ‘attribute_updated’
          args:
          attribute_id: 0
          attribute_name: on_off
          value: false
          continue_on_timeout: true
          timeout: !input ‘holdtime’
      • choose:
        • conditions:
          • condition: template
            value_template: ‘{{ not wait.trigger }}’
            sequence: !input ‘remote_button_hold_press’
            default: !input ‘remote_button_short_press’
    • conditions:
      • condition: template
        value_template: “{{ command == ‘click’ }}”
        sequence:
      • choose:
        • conditions: “{{ click_type == ‘double’ }}”
          sequence: !input remote_button_double_press
        • conditions: “{{ click_type == ‘triple’ }}”
          sequence: !input remote_button_triple_press
        • conditions: “{{ click_type == ‘quadruple’ }}”
          sequence: !input remote_button_quadruple_press
        • conditions: “{{ click_type == ‘furious’ }}”
          sequence: !input remote_button_multiple_press

I wanted to create a blueprint that would support turning on/off one light or many lights, as well as have some intelligence around the lights’ capabilities. For example, only attempt to use a color_temp value if all of the lights support that feature.

The first part was defining a blueprint input (standard stuff):

    target_light:
      description: >-
        Light or group of lights that should turn on in response to occupancy.
        Note that color temperature is supported, but only if ALL target lights
        support that feature, and the actual temperature may be limited by
        the lowest maximum value of the lights in the target group.
      name: Light
      selector:
        target:
          entity:
            domain: light

Then I created a variable to store the entity or entities:

variables:
  target_light: !input target_light

  # Make the entities variable always a list, even
  # if there is only one light in the group
  target_light_entities: >-
    {% 
      if target_light.entity_id is iterable 
        and target_light.entity_id is not string 
        and target_light.entity_id is not mapping 
    %}
      {{ target_light.entity_id }}
    {% else %}
      {{ [target_light.entity_id] }}
    {% endif %}

Then you can do things like determine if some of the lights don’t support color:

  # Loop through all the target lights...
  # If any don't support color_temp, 
  # then we don't have color support for this group of lights
  has_color_support: >-
    {% set ns = namespace(is_all_color_lights=true) %}
    {% for entity in target_light_entities %}
      {% set supported_features = state_attr(entity, 'supported_features') %}
      {% if 
        supported_features|int 
        |bitwise_and(SUPPORTED_FEATURES_COLOR_TEMP_BIT)
        == 0
      %}
        {% set ns.is_all_color_lights = false %}
      {% endif%}
    {% endfor %}
    {{ ns.is_all_color_lights }}

and determine the maximum allowable color_temp value for the lights:

  # Lowest value of max_mireds for all target lights is
  # the largest legal value for the group
  target_lights_max_color_temp: >-
    {% if not has_color_support %}
      {{ NO_COLOR_TEMP }}  
    {% else %}
      {% set ns = namespace(lowest_max_color_temp=MAX_COLOR_TEMP) %}
      {% for entity in target_light_entities %}
        {% set ns.lowest_max_color_temp = 
          [
            state_attr(entity, 'max_mireds')|int,
            ns.lowest_max_color_temp
          ]
          |min
        %}
      {% endfor %}
      {{ ns.lowest_max_color_temp }}
    {% endif %}

Then in your actions, you can use the standard stuff:

          sequence:
          - service: light.turn_on
            target: !input target_light
            data:
              brightness_pct: "{{ light_brightness_pct }}"
              color_temp: "{{ light_color_temp }}"
              transition: "{{ light_transition }}"

Hope that helps.