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: ""
trigger:
  - platform: time_pattern
    minutes: "5"
condition:
  - condition: template
    value_template: >-
      {{(states('sensor.thermometer_wohnzimmer_temperature') | float ) <
      (states('input_number.hz_solltemperatur_wohnesszimmer') | float)}}
action:
  - service: persistent_notification.create
    data:
      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?

2 Likes

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 state.xyz.state 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