Switch WebOS TV Source in automation

Can anyone help me create my first automation. My LG WebOSTV when it switches on always switches to HDMI1 but I want it to swithc to LiveTV. So I want to do an automation that detects when the tv goes on and switched the source attribute, something like:

automation:
  - alias: "Switch TV Source At Power On"
    trigger:
      platform: state
      entity_id: media_player.lounge_tv
      from: 'off'
      to: 'playing'
    condition:
      - condition: state
        entity_id: media_player.lounge_tv
        state: 'playing'
    action:

I’m not sure how to set the source attribute to LiveTV??

In case anyone wants to know how to do this, here’s what worked for me:

alias: Switch TV Source At Power On
trigger:
  platform: state
  entity_id: media_player.lounge_tv
  from: 'off'
  to: playing
condition:
  condition: state
  entity_id: media_player.lounge_tv
  state: playing
action:
  service: media_player.select_source
  entity_id: media_player.lounge_tv
  data:
    source: LiveTV
7 Likes