Temp Compare?

I put a small template together to compare the outside temp to the inside. Does anyone know how I could get the actual difference of these to temps?

  - platform: template
    sensors:
      outside_vs_inside_temp:
        value_template: "{% if states.sensor.netatmo_indoor_temperature.state < states.sensor.netatmo_outdoor_temperature.state %}Warmer Outside{% else %}Cooler Outside{%endif %}"
        friendly_name: "Temperature Compare"
{{states.sensor.netatmo_indoor_temperature.state | float -  states.sensor.netatmo_outdoor_temperature.state | float}}
2 Likes

Ah thanks. Is there a way to round the number off that it produces?

I think it should go as:
{{states.sensor.netatmo_indoor_temperature.state | round(0)-states.sensor.netatmo_outdoor_temperature.state | round(0)}}

1 Like

Yes. Thank you that works perfect

So I got the template working but the only problem is that when the temperatures hover around the same I get notifications that its warmer and then cooler outside several times.
Would anyone know how to get around this?

Some solutions I have in mind include :

  1. Make it notify only if the temperature difference is more than X degrees using a condition.
  2. In the automation that notify you, you could either disable the automation for a given amount of time once it has notified you then turn it on again after that time
  3. Using a same idea, you can create and input_boolean that will be turn_on after the notification, and you use this inut_boolean as a condition to the notify automation. (then you will need a second automation to turn it off when it has been on for X min).

Could you post your full automation so that I can more clearly what to do ?

This is what I got:

  - platform: template
    sensors:
      outside_vs_inside_temp:
        value_template: "{% if states.sensor.netatmo_indoor_temperature.state < states.sensor.netatmo_outdoor_temperature.state %}Warmer Outside{% else %}Cooler Outside{%endif %}"
        friendly_name: "Indoor Vs Outdoor"


  - alias: Notify iOS app Temp Compare Warmer Outside
    trigger:
      platform: state
      entity_id: sensor.outside_vs_inside_temp
      to: 'Warmer Outside'
    action:
      service: notify.ios_daves
      data:
        message: "It is Warmer Outside"

  - alias: Notify iOS app Temp Compare Cooler Outside
    trigger:
      platform: state
      entity_id: sensor.outside_vs_inside_temp
      to: 'Cooler Outside'
    action:
      service: notify.ios_daves
      data:
        message: "It is Cooler Outside"

So now that it is getting cooler here in Canada my temperature compare is not working right.

  - platform: template
    sensors:
      outside_vs_inside_temp:
        value_template: "{% if states.sensor.netatmo_indoor_temperature.state < states.sensor.netatmo_outdoor_temperature.state %}Warmer Outside{% else %}Cooler Outside{%endif %}"
        friendly_name: "Indoor Vs Outdoor"

Soon as the difference reaches -10 deg it changes to warmer outside.
Anyone have any ideas why?

You are probably doing string compare. Try converting them to floats as in my example above.