Automatically activate mood lighting when TV is turned on

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:

  1. A working Home Assistant installation
  2. 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.
  3. Some smart lights integrated with Home Assistant, I tend to use Philips Hue lights.

Trigger

This automation is triggered when the television goes from off to on using a State trigger.

Screenshot of Home Assistasnt that shows the automation trigger that is triggered when the TV turns on.

Here is the sunset automation trigger in YAML format:

platform: state
entity_id: media_player.living_room_tv
from: 'off'
to: 'on'

Condition

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.

Conditions in YAML:
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

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