Help needed: Boolean that turns on/off when inside temperature is higher than outside temperature

Hi there,

I created the following automation to turn on an input boolean when the temperature in a room is higher than the outside temperature. However, it does not work. Can you please review my automation and help me finding the error?

alias: Arbeitszimmer Wärmevergleich
description: ''
trigger:
  - platform: template
    value_template: >
      {{ states.sensor.netatmo_netatmo_temperature.state|float > 
           states.sensor.aussentemperatur.state|float }}
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.arbeitszimmerinnenwaermer
mode: single

I’m sure I’m missing smth. very obvious, but I can’t figure it out right now…

Thank you and have a nice afternoon!
BR TH

Is your sensor realy called sensor.netatmo_netatmo_temperature or is this a typo?

Did one of the two sensors change value during your testing? Is the automation enabled (Developer Tools -> States)? Do you get any errors in the logs?

Is your sensor realy called sensor.netatmo_netatmo_temperature or is this a typo? Did one of the two sensors change value during your testing? Is the automation enabled (Developer Tools → States)? Do you get any errors in the logs?

Thanks for the fast reply. Yes, the sensor is really called that way, and yeah, they did change states. And yes, the automation is enabled. The Log shows no errors connected to this topic…

One thing I noticed is that the > at the beginning of the value_template is always changed to a | as soon as i save the automation, which is confusing me… can this be the issue?

BR TH

Can’t you have a sensor?
If you create a sensor with the template you have then it should give you true/false without an automation.

Excerpt from my sensor_binary.yaml:

- platform: template
  sensors:
    master_bath_fan_sb:
      friendly_name: Master Fan S/B Status
      value_template: "{{ (states('sensor.master_bathroom_sensor_relative_humidity_measurement')|int - states('sensor.master_bathroom_humidity_average')|int) > states('input_number.master_bath_humidity_threshold')|int }}"

This is a binary_sensor.master_bath_fan_sb for when the humidity in my master bathroom is greater than the threshold I’ve set w/ an input_number).

Yours could be:

- platform: template
  sensors:
    inside_vs_outside_temp:
      friendly_name: Inside vs. Outside temp
      value_template: "{{ states('sensor.inside_temp')|int > states('sensor.outside_temp')|int }}"
2 Likes

Mark, I’d use |float instead of |int if the temperature states have decimal places (fractions of a degree).

And did the template in your trigger ever change from false to true during your testing? It will only trigger when it changes from false to true, if it was true and one of the sensors changed and it still is true, it will not trigger.

Thank you all. It now works, didn’t change a thing, so maybe it was some kind of very strange behaviour of the script :slight_smile:

Probably because of the thing I mentioned in my previous reply.