Condition in automation compare sensor with helper

i am trying to write a condition that compares the temperature in the room with a helper ( target temperature) in an automation.

alias: aaa_HZ_WohnEsszimmer
description: ""
  - platform: time_pattern
    minutes: "5"
  - condition: template
    value_template: >-
      {{(states('sensor.thermometer_wohnzimmer_temperature') | float ) <
      (states('input_number.hz_solltemperatur_wohnesszimmer') | float)}}
  - service: persistent_notification.create
      title: Notification Title
      message: >-
        The state of the sensor is {{
        states('sensor.thermometer_wohnzimmer_temperature') }} The helpers value
        is {{states.input_number.hz_solltemperatur_wohnesszimmer.state }}
        ConditionResult is
        {{(states.sensor.thermometer_wohnzimmer_temperature.state | float ) <
        (states.input_number.hz_solltemperatur_wohnesszimmer.state | float)}}
    enabled: true
mode: single

The notification shows the right values:
“The state of the sensor is 21.88 The helpers value is 15.5 ConditionResult is False”
But the action is always triggert.

where is my mistake?

Are you actually waiting for the time pattern trigger to test this?


Open up developer tools and use the template editor to see:

{{ states('sensor.thermometer_wohnzimmer_temperature') | float }}
{{ states('input_number.hz_solltemperatur_wohnesszimmer') | float }}
{{ states.sensor.thermometer_wohnzimmer_temperature.state | float }}
{{ states.input_number.hz_solltemperatur_wohnesszimmer.state | float }}

Are the results what you expect? You are using different logic on the output versus the condition (i.e., the output uses while the other uses the more traditional states(xyz)).

1 Like

oh embarrassing, i thought with RUNning the automation the condition would also be evaluated.
Thanks for your help!

Ah, nope, if you run it then you run it. You can do it through services to evaluate but there you go!

1 Like