I like the lights in my living room to be at a certain dim brightness level when I’m watching TV. In the past I’d have to manually turn off the ceiling lights and turn on some lamps whenever I wanted to watch TV. Now I use a Home Assistant automation to automatically set the light colour and brightness when the TV is switched on.
This automation activates a specific Home Assistant Scene when the TV is turned on. Check out my Scenes in Home Assistant YouTube video for more information about how they work and how you can use them in your smart home.
To create this automation you will need:
- A working Home Assistant installation
- A Smart Television that is integrated with Home Assistant and allows you to detect if it is on or off. I have an LG Smart TV that does this.
- Some smart lights integrated with Home Assistant, I tend to use Philips Hue lights.
This automation is triggered when the television goes from off to on using a State trigger.
Here is the sunset automation trigger in YAML format:
platform: state entity_id: media_player.living_room_tv from: 'off' to: 'on'
I check to make sure that the lights are switched on before I set the mood lighting. If the lights are not switched on, there is no point setting them to a specific colour or brightness level as it’s probably the middle of the day.
condition: or conditions: - condition: state entity_id: light.living_room_lamp state: 'on' - condition: state entity_id: light.living_room_light_strip state: 'on'
This automation uses a Service call action to activate a specific Home Assistant scene using the scene.turn_on service. The Living Room – TV Mode scene contains all my living room lights and sets them each to the colour and brightness level that I want for my mood lighting.
Full Automation in YAML
alias: 'Light: Dim living room lights when TV turns on' description: '' trigger: - platform: state entity_id: media_player.living_room_tv from: 'off' to: 'on' condition: - condition: or conditions: - condition: state entity_id: light.living_room_lamp state: 'on' - condition: state entity_id: light.living_room_light_strip state: 'on' action: - service: scene.turn_on target: entity_id: scene.living_room_tv_mode data: transition: 3 mode: single