Trying to get Ecobee fan to run based on temp differential

Hi All,

I am new to the automation/scripting stuff here and was trying to figure out how to get my Ecobee to turn on my HVAC fan when there is a temperature differential between two of its sensors. I tried looking through the scripting help but I’m struggling to piece it all together.

So far I figured out how to pull in the sensor data for one sensor but I’m not sure how to compare the two and act based on that. Is there somewhere you can point me to help me figure this out?

Any help would be appreciated!

Thanks!

I do something similar for humidity and my bath fans. I compare the outside-the-bath-humidity to the inside-the-bath-humidity in a template sensor and turn on the fan if the net difference is too high.

In configuration.yaml:

template:
  - sensor:
      - name: "Master Bath Net Humidity"
        device_class: humidity
        unit_of_measurement: "%"
        state: >
          {{ (  states('sensor.master_bath_humidity') | float 
              - states('sensor.main_hall_relative_humidity') | float
             ) | round(1)
          }}
        attributes:
          Hall: >
            {{ states('sensor.main_hall_relative_humidity') }}
          Bath: >
            {{ states('sensor.sensor.master_bath_humidity') }}

Template - Home Assistant (home-assistant.io)

Awesome thanks! Where would I put that in my config.yaml? Is there a way I can do it through the automation tab in the UI?

I had created an automation with this as the trigger:

"state_attr('climate.living_room', 'current_temperature')|float > (
states('sensor.upstairs_temperature')|float +3 ) }}"

And this as the action

service: climate.set_fan_mode
data:
  fan_mode: 'on'
target:
  entity_id: climate.living_room

Will that work?

Shouldn’t really matter if there isn’t “template:” section already defined.

Looks like it should.

I like creating the sensor for display/history purposes, but would expect the template trigger to work.

Thanks for the help. One more question as I look at your code. How to I change the differential temp between the two sensors that activates the fan?

round(1) is that the different in temp (humidity in your case)?

I leave it to the automation. Using my example, the automation would be a numeric state trigger for sensor.master_bath_net_humidity, above: 5, action: turn on fan.

You could rework it as

That’s just so I get tenths, ie 40.1%, and not 40.1001%

Cool so I got this far in the template builder in dev tools and it seems to be working but when I put it into the yaml using studio code server is lights up like a christmas tree with errors. What am I missing? Code snippet is below:

  - sensor:
      - name: "Fan on differential"
        unit_of_measurement: "°F"
        state:
          {{ (  state_attr('climate.living_room', 'current_temperature') | float 
              - states('sensor.upstairs_temperature') | float
             ) | round(1)
          }}
        attributes:
          Living room:
            {{ state_attr('climate.living_room', 'current_temperature') }}
          Upstairs:
            {{ states('sensor.upstairs_temperature') }}

The template editor is not yaml, looks like you need a few “>” added.

Assuming you are placing this in a “template:” block, try:

  - sensor:
      - name: "Fan on differential"
        unit_of_measurement: "°F"
        state: >
          {{ (  state_attr('climate.living_room', 'current_temperature') | float 
              - states('sensor.upstairs_temperature') | float
             ) | round(1)
          }}
        attributes:
          Living room: >
            {{ state_attr('climate.living_room', 'current_temperature') }}
          Upstairs: >
            {{ states('sensor.upstairs_temperature') }}

100% UNTESTED.