Defining a simple (TV) switch

I have the Samsung Smart TV integration and I’m just trying to define a simple switch or maybe input_boolean that sends On or OFF (I’m actually just interested in OFF), with no additional automation.
The controls from the integration work, however I am not sure how to plug into that and send the off signal.
The same thing I am trying to achieve for the KODI integration.

Can you please point me in the right direction? I have searched for defining a simple switch but none seemed to be close to what I wanted.

Regards

Can the TV be turned off using the integration?
Or API?
If so post how that is done and it will be easier to help

Use these services:

Use them in the tap action of a Lovelace button.

tap_action:
  action: call-service
  service: media_player.turn_off 
  service_data:
    entity_id: media_player.your_media_player_here
1 Like

Yes the Off control works. How can I investigate what request is sent when the off button is pressed?

You don’t need to. Just use the services that every media player has, I linked to them above. Your TV and Kodi will both be able to be controlled using these services.

  service: media_player.turn_off 
1 Like

I also use a Samsung TV and I just created a switch template that sends the commands to the TV. Have you installed the Samsung integration? If you did then you can use the state of the entities in the TV device to control the on/off state of your switch.

Awesome @CO_4X4, can you paste the yaml snippet?

@tom_l this looks like it’s what I need, thank you very much. I’m a bit afraid to take control of the Home Dashboard just yet though because I’m so new at this, but obviously this is the way to go forward to truly unlock HA.

Here is what I use to detect the TV power and power it on and off. I use an RM Mini remote to send IR commands but you can adapt this to your needs:

office_tv:
  friendly_name: "Office TV"
  unique_id: office_tv
  value_template: "{{states('media_player.samsung_pn51d7000')}}"
  turn_on:
    - service: remote.send_command
      data:
        entity_id: remote.office_remote
        device: television
        command: power

  turn_on:
    - service: remote.send_command
      data:
        entity_id: remote.office_remote
        device: television
        command: power
        
1 Like