How to automatically turn on Hue bulbs when TV is on?

Check out the ping page there is documentation for it, and you can use a template switch for the switch

Put this in your config:

device_tracker:
  - platform: ping
    hosts:
      your_tv: 192.168.x.x

Then automate it:

  - alias: "Turn on lights with TV"
    trigger: 
      platform: state
      entity_id: device_tracker.your_tv
      state: "on"
    action:
      service: light.turn_on
      entity_id: light.your_light

How often does it send an icmp echo-request package?

didn’t work for me, I followed your instructions and called instead of your_tv to samsung_tv and light.your_light to light.
I can see that the ‘samsung tv’ is Home (the red circle icon at the top of the page) when the TV is turned on, I can also see that it change to ‘Away’ when the TV is turned off.

device_tracker:
  - platform: ping
    hosts:
      samsung_tv: 192.168.75.17

My Automation:

- alias: "Turn on lights with TV"
  trigger:
    platform: state
    entity_id: device_tracker.samsung_tv
    state: "on"
  action:
   - service: light.turn_on
     entity_id: light.tv_light_1 

I have no clue what the problem is. I can ping the TV from my Hass RPi, and I can see when the TV is turned off, I don’t get any reply when I try to ping.

I bought an remote to my Harmony Hub, so Now I can use the Harmony Hub to turn on/off the lamp I have behind the TV.

Was just wondering, how does the config look like to turn on the light when turning on/off the TV with Harmony Hub?

you posted this before

# Set lighting for theater experience after it gets dim in the living room
- alias: 'Theater Lights'
  trigger:
    - platform: state
      entity_id: remote.living_room
      from: 'off'
  condition:
    condition: sun
    after: sunset
    after_offset: "-00:45:00"
  action:
    - service: scene.turn_on
      entity_id: scene.sunset
    - delay: 00:02:00
    - service: scene.turn_on
      entity_id: scene.sunset_dimmed

Where do I put in you config example what light I would like to turn on (in my case ‘light.tv_light_1’) or do I need some more config to get it to work?

I’m using a number of different lights together in a scene. Here’s what that scene looks like:

- name: Sunset
  entities:
    light.lightstrip4:
        state: on
        transition: 2
        brightness: 254
        xy_color: [ 0.5384, 0.445 ]
    light.lightstrip2:
        state: on
        transition: 2
        brightness: 251
        xy_color: [ 0.5493, 0.4351 ]
    light.lightstrip3:
        state: on
        transition: 2
        brightness: 254
        xy_color: [ 0.6168, 0.3737 ]
    light.tv_light_l:
        state: on
        transition: 2
        brightness: 236
        color_temp: 500
        xy_color: [ 0.6735, 0.322 ]
    light.tv_light_r:
        state: on
        transition: 2
        brightness: 236
        color_temp: 500
        xy_color: [ 0.6735, 0.322 ]

In your case, since you just want to control one light, it would look like this:

# Set lighting for theater experience after it gets dim in the living room
- alias: 'Theater Lights'
  trigger:
    - platform: state
      entity_id: remote.living_room
      from: 'off'
  condition:
    condition: sun
    after: sunset
    after_offset: "-00:45:00"
  action:
    - service: light.turn_on
      entity_id: light.tv_light_1
      data:
        brightness: 254
    - delay: 00:02:00
    - service: light.turn_on
      entity_id: light.tv_light_1
      data:
        brightness: 100

That will turn on the light at full brightness, wait two minutes and then set the brightness to less than half. If your lights support it, you can add a transition value like I did in the scene to give it the real theater effect.

Thanx for your config example, it’s working now, but I find it little bit annoying that there seems to be some delay between the TV turned on and the light turns on and same for when turning off the TV and the light turn off.

how long does it take between from your TV turned on from the Harmony Hub and the light goes on?

Here’s my config for harmony:

remote:
  - platform: harmony
    name: living_room
    host: 192.168.75.32

and here’s the automation for the light:

automation:    
#TV Lights ON
- alias: 'TV-Lights On'
  trigger:
    - platform: state
      entity_id: remote.living_room
      from: 'off'
  action:
    - service: light.turn_on
      entity_id: light.tv_light_1
#TV Lights ON
- alias: 'TV-Lights Off'
  trigger:
    - platform: state
      entity_id: remote.living_room
      from: 'on'
  action:
    - service: light.turn_off
      entity_id: light.tv_light_1

Can you see if anything is wrong, or is there anyway to speed up the status report between Hass and Harmony?

This is because the state of the harmony sensor is only updated once every 30 seconds I believe. So you turn on the harmony, and sometime within the next 30 seconds when the state is updated next is when the light will turn on.

There isn’t much you can do to change it if you turn on the harmony remotely (like thru the controller). But if you turn on the harmony thru home assistant than you can turn the light on at the same time if you write a script for that.

1 Like