I’d like to set the brightness level on all the lights by using a code that is more simple than the code I use below. I am actually repeating the same code for each light so there have to be a better way to do this.
As far as I know, there is no way to set the brightness level on a group, just on individual lights.
- alias: "Turn lights on / of for the cleaning lady"
trigger:
platform: state
entity_id: sensor.cleaning_lady_home
action:
- service: homeassistant.turn_on
entity_id:
- light.taklampa_vardagsrum_soffan_level
data_template:
brightness: >
{% if is_state('sensor.cleaning_lady_home' , 'true') %} 255
{% else %} 0
{% endif %}
- service: homeassistant.turn_on
entity_id:
- light.taklampa_vardagsrum_bokhyllan_level
data_template:
brightness: >
{% if is_state('sensor.cleaning_lady_home' , 'true') %} 255
{% else %} 0
{% endif %}
- service: homeassistant.turn_on
entity_id:
- light.taklampa_ovre_trapphall_level
data_template:
brightness: >
{% if is_state('sensor.cleaning_lady_home' , 'true') %} 255
{% else %} 0
{% endif %}
…and so on and on for all the lights in the house.