Switch for Hisense TV with HomeKit and Broadlink

Hello everybody,

I have a Hisense TV that I turn on and off via Broadlink.

The HomeKit integration gives me the status of whether the television is on or off.

How can I create a switch that switches on and off via Broadlink and gets the status from the Homekit.

On my devices that have no integration, I put on power metering plugs to know if the device is using any electricity - then I can derive the status of it from that. If you have a streaming device attached, like Apple TV, you can use the state of the Apple TV to help too (i.e., suspend = TV off, playing = TV on).

I need help, how i code this in yalm.

I have the status whether on or off.

Unfortunately, the support here is very limited. However, I managed to resolve the issue with the help of ChatGPT. If you’re curious, here’s how I did it:

switch:
  - platform: template
    switches:
      fernseher_wohnzimmer:
        friendly_name: "Fernseher Wohnzimmer"
        value_template: "{{ is_state('media_player.hisense_fernseher_airplay', 'on') }}"
        turn_on:
          service: remote.send_command
          data:
            entity_id: remote.infarot_sender
            device: tv
            command: turn_on
        turn_off:
          service: remote.send_command
          data:
            entity_id: remote.infarot_sender
            device: tv
            command: turn_on