Comparing against a float in Automation

1 of my automation condition is this line {{ states('sensor.vindriktning_sht3x_temperature') | int(0) >= 25 }}, and it currently works, i.e. once the temperature is 25 or above

I changed it to {{ states('sensor.vindriktning_sht3x_temperature') | float(0) >= 25.5 }}, but it no longer works, i.e. action does not run even when temperature is 25.8

Any idea what might be the issue?

image

Results are:
29.2
29.2
True

These results indicate my automation should work… right? Strange

alias: When to set aircon fan speed to high
description: >-
  make aircon use high fan speed if between 2 temperatures
trigger:
  - platform: state
    entity_id:
      - sensor.vindriktning_sht3x_temperature
condition:
  - condition: and
    conditions:
      - condition: template
        alias: temp >= 25.5
        value_template: "{{ states('sensor.vindriktning_sht3x_temperature') | float(0) >= 25.5 }}"
      - condition: template
        alias: temp < 26
        value_template: "{{ states('sensor.vindriktning_sht3x_temperature') | int(0) < 26 }}"
      - condition: state
        entity_id: climate.mitubishi_ac
        state: cool
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.mitubishi_ac
            attribute: fan_mode
            state: high
action:
  - service: climate.set_fan_mode
    data:
      fan_mode: high
    target:
      entity_id: climate.mitubishi_ac

There are 3 of these automations currently, this is the one that needs to use float

  1. If AC is turned on (cool) and measured temp is >=26C: max fan speed
  2. If AC is turned on (cool) and measured temp is >=25.5 + <26C: high fan speed
  3. If AC is turned on (cool) and measured temp is <25: auto fan speed (after a while, temp will rise to 25.6, triggering max fan speed again)

This automation was created because there is something wrong with the AC’s temp sensor and I can’t seem find a solution

thanks! let me give it a shot

Thanks, there were 1 issue,

  1. temp < 25.5: 'auto' } %} should be temp < 25
alias: AC example
description: When AC is `cool`, set `fan_mode` depending on current measured temperature
trigger:
  - platform: state
    entity_id:
      - sensor.vindriktning_sht3x_temperature
    to: null
  - platform: state
    entity_id:
      - climate.mitubishi_ac
    to: cool
condition:
  - condition: template
    value_template: "{{ is_state('climate.mitubishi_ac', 'cool') }}"
action:
  - variables:
      wanted_fan: |
        {% set temp = states.sensor.vindriktning_sht3x_temperature | float(0) %}
        {% set fan_modes = { 
               temp >= 25.6: 'max',
               25.5 <= temp < 25.6: 'medium',
               temp < 25: 'auto' 
           } %}
        {{ fan_modes.get(true) }}
  - condition: template
    value_template: "{{ not is_state_attr('climate.mitubishi_ac', 'fan_mode', wanted_fan) }}"
  - service: climate.set_fan_mode
    data:
      fan_mode: "{{ wanted_fan }}"
    target:
      entity_id: climate.mitubishi_ac

I added another trigger so that the temperature will be checked once AC is cool, but the line value_template: "{{ not is_state_attr('climate.mitubishi_ac', 'fan_mode', wanted_fan) }}" keeps returning false, blocking the fan_mode change.

I even added a 5 second delay before the line, but still being blocked.

Any idea why?

for the temp, I did not want the fan speed to keep oscillating between auto and medium, so idea was if it goes below 25, set to auto and stay there until temperature hits 25.5, then set to medium

I could not determine the value of wanted_fan, it just did not show in the trace. Let me try to get a screenshot.

image

The trigger was because the AC turned cool.
wanted_fan was auto, even though current temp is 30C.

This line fixed the issue {% set temp = states('sensor.vindriktning_sht3x_temperature') | float(0) %}
states.sensor.vindriktning_sht3x_temperature kept returning 0

        {% if (temp > 25.6) %}
            max
        {% elif (temp >= 25.5 and temp <= 25.6) %}
            medium
        {% elif (temp < 25.0) %}
            auto
        {% endif %}  

Thanks, I used the above eventually for readability. The idea is to take no action from 25 to 25.4 so that the fan speed doesn’t keep oscillating between auto and medium