Load power temporary sensor

Hello,

I’m trying to create temporary sensor which shows proper load power attribute from xiaomi switch. The problem I have with the switch is that it shows ‘None’ instead of 0.0W in it’s attributes. My code looks like that at the moment:

      washing_machine_load_power_level:
        friendly_name: Obciążenie mocy Pralka Łazienka
        value_template: >-
         {% if state_attr('switch.xiaomi_miio_switch', 'load_power') != ('unavailable' or 'unknown' or 'None') %}
             0.0
          {% else %}
            {{ state_attr('switch.xiaomi_miio_switch', 'load_power') }}             
            {% endif %}
        unit_of_measurement: "W"

but unfortuntely it shows 0.0W all the time (i checked the switch entity and it shows for example 1 in 'Load power" attribute. What am I doing wrong? Thank you in advance for any advice.

Of course it does :

{% if state_attr('switch.xiaomi_miio_switch', 'load_power') not equal to ('unavailable' or 'unknown' or 'None') %}
             0.0
2 Likes

OK, I changed code to:

      washing_machine_load_power_level:
        friendly_name: Obciążenie mocy Pralka Łazienka
        value_template: >-
         {% if state_attr('switch.xiaomi_miio_switch', 'load_power') == ('unavailable' or 'unknown' or 'None') %}
             0.0
          {% else %}
            {{ state_attr('switch.xiaomi_miio_switch', 'load_power') }}             
            {% endif %}
        unit_of_measurement: "W"

and it shows the correct W amount besides when it gets None status. The entity looks like that:
problem
instead 0.0 W.