Value template problem

I’ve a little value template problem with if/else statement. This is my mqtt sensor configuration:

  - platform: mqtt
    name: "KC gas"
    state_topic: "state"
    qos: 0
    value_template: >-
            {%- if value > '200' %}
                Allarme
            {% else  %}
                Normale
            {%- endif %}

HA receive mqtt message correctly but value change in “Allarme” when mqtt payload is greater then 20 and not 200. Where’s the error? I tried to change from {%- if value > ‘200’ %} to {%- if value > “200” %} but with the same result.

Try {%- if value | float > 200 %}

2 Likes

you solved it, I had a similar problem and looking for couple of days
thank you!