Toggling LG TV with webOS

If you just use google to call them, I’d setup scripts to turn on for each of the sources, just tv on and tv off.
I’d also have a button card with buttons to call all the scripts
You’ll need to experiment with the delay, my tv needs ~9 seconds before its ready

1 Like

Yeah working, with 15 sec delay
Will do as you say use google and buttons to call the script

Have a look here, might be of some use:

1 Like

Cool! Didnt know of that one, thx !

I changed the scripts, cause it was sometimes putting on when off and vice versa
This is what i have so far but i get errors

##############################
## TV aanzetten
##############################
tv_aanzetten:
  alias: Activiteit TV kijken
  icon: "mdi:television"
  sequence:
    choose:
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "off"
        sequence:
          - service: media_player.turn_on
            entity_id: media_player.living_tv
          - delay: 00:00:15
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "on"
          - condition: template
            value_template: '{{is_state_attr("media_player.living_tv","source","HDMI2")}}'
        sequence:
          - service: media_player.turn_off
            entity_id: media_player.shield_tv 
      - service: media_player.select_source
        target:
          entity_id: media_player.living_tv
        data:
          source: TV VLAANDEREN
            
            
##############################
## Netflix aanzetten
##############################
netflix_aanzetten:
  alias: Activiteit Netflix kijken
  icon: "mdi:netflix"
  sequence:
    choose:
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "off"
        sequence:
          - service: media_player.turn_on
            entity_id: media_player.living_tv
          - delay: 00:00:15
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "on"
          - condition: template
            value_template: '{{is_state_attr("media_player.living_tv","source","HDMI2")}}'
        sequence:
          - service: media_player.turn_off
            entity_id: media_player.shield_tv      
      - service: media_player.select_source
        target:
          entity_id: media_player.living_tv
        data:
          source: Netflix
  

##############################
## Film aanzetten
##############################
film_aanzetten:
  alias: Activiteit Film kijken
  icon: "mdi:movie-open-outline"
  sequence:
    choose:
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "off"
        sequence:
          - service: media_player.turn_on
            entity_id: media_player.living_tv
          - delay: 00:00:15
          - service: media_player.turn_on
            entity_id: media_player.shield_tv
      - conditions:
          - condition: state
            entity_id: media_player.living_tv
            state: "on"
          - condition: template
            value_template: '{{not is_state_attr("media_player.living_tv","source","HDMI2")}}'
        sequence:
          - service: media_player.turn_on
            entity_id: media_player.shield_tv
      - service: media_player.select_source
        target:
          entity_id: media_player.living_tv
        data:
          source: HDMI2
  
##############################
## TV uit
##############################  
tv_uit:
  alias: Activiteit Off
  icon: mdi:power
  sequence:
    choose:
      - conditions:
          - condition: template
            value_template: '{{is_state_attr("media_player.living_tv","source","HDMI2")}}'
        sequence:
          - service: media_player.turn_off
            entity_id: media_player.shield_tv  
      - service: media_player.turn_off
        entity_id: media_player.living_tv

The errors i get

  • Invalid config for [script]: [service] is an invalid option for [script]. Check: script->sequence->0->choose->2->service. (See /config/configuration.yaml, line 58).
  • Invalid config for [script]: [service] is an invalid option for [script]. Check: script->sequence->0->choose->1->service. (See /config/configuration.yaml, line 58).
1 Like

Think you need to add target:

Have a look at the scripts docs there’s examples there

Fixed it :slight_smile: