The used value is not accurate

Hi :slight_smile:

I used this code:

    - name: "96H warm actuele temperatuur is hoger dan maximum"
      icon: mdi:check
      state: >
        {%- if states('sensor.openweathermap_temperature') | float > states('input_number.96h_warm_maximaal_gemeten_temperatuur') | float -%}
          true
        {%- else -%}
          false
        {%- endif %}
      #Laatste update van bovenstaand
    - name: "Laatste update 96H max"
      icon: mdi:calendar
      state: >
        {{ ((as_timestamp(now()) - as_timestamp(states("input_datetime.96h_warm_tijdstip_max_updatet"))) / 3600 )| float | round(2) }}
      #Actuele temperatuur is lager
    - name: "96H warm actuele temperatuur is lager dan minimum"
      icon: mdi:check
      state: >
        {%- if states('sensor.openweathermap_temperature') | float > states('input_number.96h_warm_minimaal_gemeten_temperatuur') | float -%}
          false
        {%- else -%}
          true
        {%- endif %}
      #Laatste update van bovenstaand
    - name: "Laatste update 96H min"
      icon: mdi:calendar
      state: >
        {{ ((as_timestamp(now()) - as_timestamp(states("input_datetime.96h_warm_tijdstip_min_updatet"))) / 3600 )| float | round(2) }}

The code is functional for 90% but I’ve got a issue with the next part:

      #Actuele temperatuur is lager
    - name: "96H warm actuele temperatuur is lager dan minimum"
      icon: mdi:check
      state: >
        {%- if states('sensor.openweathermap_temperature') | float > states('input_number.96h_warm_minimaal_gemeten_temperatuur') | float -%}
          false
        {%- else -%}
          true
        {%- endif %}

He doesn’t use the actual value. He is rounding the values the compare the state with another. If the state is around the 0,5 the answer is true. But I want to use the actual value and not a rounding value.
Does any one know what I do wrong?

The problem now is that went the vallues are fast the same the result is the whole time “true”.

Thank you,
Tom

The float filter doesn’t round the value.

Thank you for you’ re reaction.
I tried it in the development tool. I changed my code to:

    - name: "96H warm actuele temperatuur is lager dan minimum"
      icon: mdi:check
      state: >
        {{ states('sensor.openweathermap_temperature') | float < states('input_number.96h_warm_minimaal_gemeten_temperatuur') | float }}

but the result is the same. That means the code doesn’t make the issue, but what can make that happend to?

Can it be the problem came from one of the sensoren?

Copy-paste the following template into the Template Editor and let me know what it reports.

{{ states('sensor.openweathermap_temperature') }}
{{ states('input_number.96h_warm_minimaal_gemeten_temperatuur') }}
{{ states('sensor.openweathermap_temperature') | float < 
  states('input_number.96h_warm_minimaal_gemeten_temperatuur') | float }}

Hi 123,

I only need to say thank you.

I reed you’re reaction and I was thinking… Hmm…
Dit I used the same sensor in the automation if in the template file. And the answer was no. I use ‘sensor.gemiddelde_buiten_temperatuur’.
:sweat_smile: That is a logical solution for the problem that was not a problem.
Thank you for your reaction.

    - name: "96H warm actuele temperatuur is lager dan minimum"
      icon: mdi:check
      state: >
        {%- if states('sensor.gemiddelde_buiten_temperatuur') | float > states('input_number.96h_warm_minimaal_gemeten_temperatuur') | float -%}
          false
        {%- else -%}
          true
        {%- endif %}