Hey everyone, I’m trying to create an automation that dims all the lights in my living room to 50% of their current brightness at 11:30 PM. I’ve got all my living room lights grouped together in a light group called light.living. I’ve also figured out how to get a list of all the lights that are currently on using this template:
{{ state_attr(‘light.living’,‘entity_id’)|expand|selectattr(‘state’,‘eq’,‘on’)|map(attribute=‘entity_id’)|list }}
This gives me a list like ["light.light1", "light.light2"], which is exactly what I need. The basic structure of the automation is straightforward, but I’m stuck on how to get this list of lights into the action part of the automation. Here’s what I have so far:
yaml
automation:
- alias: Dim Lights at Night
mode: single
trigger:- platform: time
at: ‘23:30’
condition: - condition: state
entity_id: light.living
state: ‘on’
action: - service: light.turn_on
data:
brightness_step_pct: 50
target:
entity_id: {{ some template }}
- platform: time
I’m not sure how to properly use the template in the target section to reference the list of lights. I’ve tried a few things, but nothing seems to work. If anyone has any tips or advice on how to get this working, I’d really appreciate it! Maybe there’s a different approach or a specific way to format the template. Let me know your thoughts!
Thanks in advance!
Best regards,
[Your Name]