I am working on an automation and would like some input from the community. I am attempting to change light colors when watching TV in the living room. I also want to set the brightness up and down based on the sun’s elevation. Not sure if this is the best way, but wanted to ping the community for feedback:
alias: Living Room - Roku Ultra Light Change 12-31-2025
description: Change color based on Roku Ultra app selection
triggers:
- entity_id: media_player.living_room_ultra
attribute: source
trigger: state
- trigger: state
entity_id:
- media_player.livingroomstereo
attribute: source
to:
- CBL/SAT
id: cable
- trigger: state
entity_id:
- media_player.livingroomstereo
attribute: source
to:
- Roku
id: roku
- trigger: time_pattern
minutes: "5"
conditions:
- condition: state
entity_id: input_boolean.automations_kill_switch
state: "off"
actions:
- target:
entity_id:
- light.wled_lr_left
- light.wled_lr_right
- light.wled_lrtop
data:
color_name: >
{% set app_colors = {
'Netflix': 'red',
'Disney Plus': 'turquoise',
'Prime Video': 'blue',
'Hulu': 'green',
'YouTube': 'red',
'Xfinity Stream': 'orchid',
'HBO Max': 'darkorchid',
'Fandango at Home': 'royalblue',
'ESPN': 'red',
'NFL': 'green',
'HISTORY': 'yellow',
'Amazon Music': 'blue',
'MLB': 'green',
'Movies Anywhere': 'cyan',
'Peacock TV': 'teal',
'Pluto TV - Free Movies/Shows': 'yellow',
'Home': 'antiquewhite'
} %} {% set current_app = state_attr('media_player.living_room_ultra',
'source') %} {{ app_colors.get(current_app, 'antiquewhite') }}
action: light.turn_on
- choose:
- conditions:
- condition: trigger
id:
- cable
sequence:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.wled_lr_right
- light.wled_lr_left
- light.wled_lrtop
data:
color_name: purple
- conditions:
- condition: trigger
id:
- roku
sequence:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.wled_lr_right
- light.wled_lr_left
- light.wled_lrtop
data:
color_name:
"[object Object]": null
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.wled_lr_right
- light.wled_lr_left
- light.wled_lrtop
data:
brightness_pct: >
{% set elevation = states('sensor.sun_solar_elevation') | float(0) %} {%
set min_elevation = -6 %} # Civil twilight start {% set max_elevation =
10 %} # Full daylight point
{# Scales brightness between 10% (dark) and 100% (bright) #} {% set
brightness = ((elevation - min_elevation) / (max_elevation -
min_elevation) * 90) + 10 %}
{# Clamps value between 10 and 100 #} {{ [10, [brightness, 100]|min]|max
| int }}
transition: 5
mode: single