Sensor: wattage to status information

Hi all.

As a newbie, struggling a bit with a sensor that should give status of a device based on electricity consumption.

In my configuration.yaml under templates section, I have a following sensor defined. When ever a device takes more than 0Watts, it’s status should change to ‘On’. But for some reason (I know it will be a stupid one) not able to get it working. I’ve done some other from string to numeric sensors with success, but this just doesn’t work. I’ve tried many different formats / syntax with no luck. I am only seeing “unavailable” status when looked at the States view.

The source gives 0.0 as a value when the device is not taking any power.

Thankful for any help,
-k

  - sensor:
    #eelin patteri on/off
    - name: "eeli lämmitys"
      unique_id: "eeli_lammitys"
      state: >- 
        {% if states('sensor.lammitys_eeli_power')|float(0) > 0|float(0) %}
          On
        {% else %}
          Off
        {% endif %}