Is it possible to change brightness of lights that are turned on? If I use the the lights.turn_on service on an area, and some of the lights are turned off based on a scene, and I change the brightness, the lights that are off are turned on.
I tried different things:
Script that creates a group of lights when any of the lights change status (sensor that counts lights that are on)
Script that increase the brightness of the lights that are turned on
But I’m running into limitations (or lack of understanding) for both approaches.
create_group_living_room_lights_on:
mode: queued
alias: Create 'living room lights' group for every turned on lights
icon: mdi:lightbulb
sequence:
- service: group.set
data_template:
name: "Living room lights on"
object_id: "living_room_lights_on"
entities: >
{% for light in
expand(states.light)
|selectattr('state', 'eq', 'on')
|selectattr(('state', 'eq', 'on') and 'entity_id', 'in', area_entities('Living room'))
|map(attribute='entity_id')
|list
-%}
- {{ light }}
{% endfor %}
Just add all the light you have in this fashion and it will get the job done. You can turn this automation into a lot of different things with adding Trigger ID’s and expanding it. Hope this helps.
I believe it depends largely on what brand/model of light you are using - my LIFX bulbs only recognise some of the options for colour and brightness. You will probably need to do a web search or three, and some experimenting.
If you refer to the documentation for area_entities you will see that it can only accept one area name. Therefore this invention of yours, to “add” area names together, can’t work.
area_entities('Living Room' + 'Dining Room')
The result of area_entities is a list and you can combine lists so I suggest you provide expand with a combined list like this: