Tv switch based on current via device

Ignore the on off commands, they should work. They’re based off something else. But I’m trying to get the state working.


- platform: template
  switches:
    tv:
      unique_id: tv
      value_template: "{{ states('sensor.kogan_01_current') > 0 }}"
      turn_on:
        service: remote.send_command
        data:
          entity_id: remote.living_room_remote
          device: tv
          command: poweron
      turn_off:
        service: remote.send_command
        data:
          entity_id: remote.living_room_remote
          device: tv
          command: poweroff

It’s a tuya device. And if I look at the state I can see current is currently

Should I be able to compare the state of that device to 0?

States are strings. Try:

value_template: "{{ states('sensor.kogan_01_current') | int(0) > 0 }}"

Or this if the power is a fraction of a Watt (unlikely)

value_template: "{{ states('sensor.kogan_01_current')|float(0) > 0 }}"

You beauty. That worked