Hi everybody,
I’m trying to change the brightness of all enables lights without bothering the ones that are off with the following script:
light_brightness_time:
sequence:
- service: light.turn_on
data_template:
brightness_pct: "{{ states('input_number.light_brightness') | int }}"
entity_id: >
{%- for state in states.light %}
{%- if state.state == 'on' %}
- {{ state.entity_id }}
{%- endif %}
{%- endfor %}
The template engine’s output looks correct to me:
light_brightness_time:
sequence:
- service: light.turn_on
data_template:
brightness_pct: "100"
entity_id: >
- light.kitchen
- light.kitchen1
- light.kitchen2
- light.kitchen3
- light.zigbee_group_light_kitchen
I confirmed this is working by executing the code above (without the ‘>’). But HA does not agree with the conditional code since I receive the following error:
Error executing script script.light_brightness_time. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data['entity_id']
After hours of searching I hope one of you can point me in the right direction or tell me how to properly format the entity_id part!