I cannot find a way to pass a dynamic list of entity ids to browser_mod popup call for the right_button_action.
My Home Assistant version:
- Core 2024.3.3
- Supervisor 2024.03.1
- Operating System 12.1
- Frontend 20240307.0
Steps
- Create a dynamic sensor to hold all light entites that are currently on
- platform: template
sensors:
lights_on:
unique_id: 82ef8b36-5843-4ed8-bf73-7f178d60721e
friendly_name: Lights On
unit_of_measurement: entities
icon_template: "{{ 'mdi:lightbulb-outline' if is_state('sensor.lights_on','0') else 'mdi:lightbulb-on-outline' }}"
value_template: >
{{ states.light
| selectattr('state','in',['on'])
| rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))
| rejectattr('entity_id','search','(_screen)')
| list
| count }}
attribute_templates:
entities: >
{{ states.light
| selectattr('state','in',['on'])
| rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))
| rejectattr('entity_id','search','(_screen)')
| map(attribute='entity_id')
| list }}
- Call the light.turn_off service on the right action button.
...
right_button: ALL OFF
right_button_action:
service: light.turn_off
data:
entity_id:
template: '{{ state_attr(''sensor.lights_on'', ''entities'') }}'
The above code shows this error.
Failed to call service light/turn_off. not a valid value for dictionary value @ data['entity_id']
Also tried providing the entity id list this way, which is the way it works if I call the service from developer tools.
...
entity_id: >
{{ state_attr('sensor.lights_on', 'entities') }}
But when I save it turns into:
...
entity_id: |
{{ state_attr('sensor.lights_on', 'entities') }}
This code does not produce an error but then it does not turn off the lights either.
what am I doing wrong?