Switch media_player only off works


i have several switches but in one of them (LG TV on/off) only half of the switch works: turn_off.

turn_on doesnt work.

  - platform: template
          value_template: "{{ is_state('media_player.tv', 'on') }}"
            service: media_player.turn_on
              entity_id: media_player.tv
            service: media_player.turn_off
              entity_id: media_player.tv

Any idea? thanks!

It could be the TV that is the “limit”.
My TV also has an API (no integration in HA) that I can use to select input and turn off. But I can’t turn on since the API is off when the TV is off.
Same thing with the app that is built for the TV. I can switch off but not on.

I can power it on via command by running:

echo 'on 0' | cec-client -s -d 1

the problem is i cannot mix a switch based ‘template’ and another based ‘command_line’

You could have turn on action be running a script, or won’t that work?

yes. I have a command_on to power it on:

        command_on: >
         ssh -i id_rsa -o StrictHostKeyChecking=no [email protected] "sudo echo 'on 0' | cec-client -s"

yes… Add this to a script, then add the script to the template media player

Sorry i dont know how. :thinking: Can you give me a hand on this?

I only have my phone so it’s hard to see everything.

Configuration -> Scipts -> add script.
As action you call service to run this command, whatever command it is.

Then in your template media player

  service: script.the_script_you_created

Something like that. It’s hard to test it from the phone.

OK now i understand what you meaning. Sorry was a traslation issue. Thanks!