Trigger with samsung tv state

I’ve been strugglor for a couple of hours to get this simple automation to work. But I can get it to work.

The devices a got is these, an ordenary switch:

switch.gillestuga_golvlampa

and an mediaplayer:

media_player:
      - platform: samsungtv
        name: tvcellar
        host: 192.168.x.y
        port: 8001

The automation that I can’t get to work looks like this:

- alias: Turn on lamp when tv turns on
  hide_entity: False
  trigger:
    platform: state
    entity_id: media_player.tvcellar
    from: 'off'
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: switch.gillestugan_golvlampa

Can anyone see whats wrong with this?

Hi,

I think it should be switch.turn_on instead of service: homeassistant.turn_on

It didn’t work.

I’m thinking if it can have something to do with that I didn’t have to accept Home Assistant in my TV, have read that I should have to do that on a samsung tv, but my tv didn’t ask for that.

Hope someone can help me with this.

Take a look at your states tab. the <> tab in the right menu bar of the front end. Is that state of your TV ‘on’ or ‘On’? Having the wrong state (capitalization matters) will make it not trigger.

Should work like this:

alias: Living TV ON

trigger:

  • entity_id: media_player.tvcellar
    from: ‘off’
    platform: state
    to: ‘on’
  • action:
    • data:
      entity_id: switch.gillestugan_golvlampa
      service: switch.turn_on

When I’ve changed to mp1111:s first suggestion everything works, it was just that I didn’t wait long enough to see that it worked.

Thanks for your help.