Getting difference between value of two sensors

Hello folks, I have two ecobees where they spit out temperature and humidity and I can track them in the history fine. Also using yo.no I am having my outdoor temperature and humidity added as a sensor. I am really interested in plotting the difference between the two temperatures. Any thoughts on how to do this either through influxdb and grafana or HA history/sensor component?

2 Likes

You could create a sensor that does simple math on the two other entities, then just simply graph that sensor.

Thanks, for the suggestion but I am relatively new to HA, how can I go about doing this?

Ahhā€¦are you familiar at all with how templates work?

Not at all :sleepy:

Thatā€™s where you need to start. Are you on HASS.io or a different version of Home Assistant? Whatā€™s your environment look like?

I am running on NUC through virtual box. Be honest with you I even donā€™t have a single automation script everything goes through node red.

Iā€™d use a template sensor and something like thisā€¦just change the entities for your ecobee and outside temperature sensor.

sensor:
  - platform: template
      indoor_outdoor_temp_diff:
        entity_id:
          - sensor.home_temperature 
          - sensor.dark_sky_apparent_temperature
        value_template: >-
          {% set ecobee = states.sensor.home_temperature.state|float %}
          {% set outdoor = states.sensor.dark_sky_apparent_temperature.state| float %}
          {{ outdoor - ecobee }}
1 Like

Awesome, I will try it tonight. Thank you so much.

Thanks @Jer78 that was perfect for what I was looking for too. There was one line missing that I needed to add to my config in case anyone else comes across it. I also rounded down the float for readability.

  - platform: template
    sensors:
      indoor_outdoor_temp_diff:
        entity_id:
          - sensor.living_room_temperature
          - sensor.dark_sky_apparent_temperature
        value_template: >-
          {% set esphome = states.sensor.living_room_temperature.state|float %}
          {% set outdoor = states.sensor.dark_sky_apparent_temperature.state| float %}
          {{ (outdoor - esphome)|round(1) }}
2 Likes

Sorry for the thread hijack but I have the same question. The following works in the template tool (in developer tools) but is failing when I do a ā€œha core checkā€.

Any ideas?

- alias: Rumpus Light Left On
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d0002b84fd3
    to: 'off'
  condition:
    - condition: template
      value_template: {{ states('sensor.illumination_158d0002b84fd3') | float > ( states('sensor.wupws_solarradiation') | float / 0.0079 )  }} 
  action:
    - service: notify.gav_bullet
      data_template:
        message: "Light might be left on"                 

Sorry, do you mean ā€˜configuration checkā€™ ?
Can you post the error you get ?

Edit: No, my blindness, single line templates require (double, in this case) quotes.

So : -

value_template: "{{ states('sensor.illumination_158d0002b84fd3') | float > ( states('sensor.wupws_solarradiation') | float / 0.0079 ) }}" 

Though you should get away with : -

value_template: "{{ states('sensor.illumination_158d0002b84fd3') | float > states('sensor.wupws_solarradiation') | float / 0.0079 }}"
1 Like

Thanks @Mutt that was it!

I use this template sensor which does work, however if I look at the value of the sensor it just sayā€™s active. I want to see the value in degrees however. The goal is to create an automation that triggers if the temperature difference between two rooms is hoger than 2 degrees a blower switches on which blows the warmer air from the hottest room to the other colder room.

I use this YAML code:

# Calculated Value Sensor
# Temperature difference between Magazijn en Entree
  - platform: template
    sensors:
      magazijn_entree_temp_diff:
        entity_id:
        - sensor.temp_magazijn_temperature 
        - sensor.temp_entreeruimte_temperature
        value_template: >-
          {set magazijntemp = states.sensor.temp_magazijn_temperature.state| float }
          {set entreetemp = states.sensor.temp_entreeruimte_temperature.state| float }
          {{ (magazijntemp - entreetemp)|round(1) }}

What am I doing wrong here?

ok - all seem to bo clear ā€¦
but - beginner quesion - where do I write this!?

writing this in my configuration, iā€™ll only get errors ā€¦
solved - no idea how or why I got the error bevore

would be great, if I could use only the combining helper for this usecase
like the ā€œCombine Helperā€- icon suggested:
image

8 Likes