HVAC Working Overtime Sensor - Window or Door Left Open

I saw a Reddit post with a screenshot of an alert from a Nest Thermostat saying, “Your heating system failed to heat your home: Based on your local weather and recent heating system performance, your home should’ve become warmer while the heat was on {date/time} to {date/time}. Instead, the temperature decreased by 5 degrees F…Did you leave a window or door open?..”

I though this was a fantastic idea: to create a sensor that would detect if a window or door may be left open based on the observation that the thermostat was working overtime (cycling more than would be expected for the delta between the outdoor temperature and the indoor thermostat set point) rather than putting contact sensors on every door or window in the house.

Thinking how to build this sensor, I discovered it was possible to track how long the thermostat was heating today. I also discovered that it was possible to track the ratio of heating time to idle time with the history stats sensor platform. Thus, one could create a sensor to track the ratio of heating time over the last two hours.

template:
  - sensor:
      - name: HVAC Activity
        state: "{{ state_attr('climate.living_room', 'hvac_action') }}"
sensors:
  - platform: history_stats
    name: Heating Ratio Two Hours
    entity_id: sensor.hvac_activity
    state: 'heating'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 2

To build an overtime sensor, one would need to know the current heating time ratio relative to the delta temperature (the difference between the thermostat set point and the outdoor temperature) and compare this against the typical heating time ratio relative to the delta temperature. It is normal for the thermostat to cycle more when the difference between the thermostat set point and the outdoor temperature is greater, but I want to know when this becomes abnormal. This could be done with a threshold sensor helper.

template:
  - sensor:
      - name: HVAC Heating Activity Ratio Relative to Temp
        state: "{{iif(((state_attr('climate.living_room','temperature')|replace('None',states('sensor.living_room_current_temperature'))|int)-states('sensor.openweathermap_temperature')|int)==0,0,((states('sensor.heating_ratio_two_hours')|replace('unknown',0)|float)/((state_attr('climate.living_room','temperature')|replace('None',states('sensor.living_room_current_temperature'))|float)-states('sensor.openweathermap_temperature')|float)*100))}}"

Now, I will have to track this HVAC Heating Activity Ratio Relative to the Delta Temperature over the next few weeks to configure this abnormal activity threshold.

Has anyone built something similar? Any ideas?

I don’t think the correct solution is seeing when the current temperature remains lower than the thermostat set point for a protracted duration of time while heating. This would only detect when the furnace was not able to keep up with the thermal loss from an open window. Instead, I want to detect when the thermostat efficiency is markedly decreased, even if the furnace is able to reach the set point.

Edit: Control for Divide By Zero, None, and Unavailable entities when thermostat is off

Your History Stats sensor is set to only record 22:00-00:00… get rid of the .replace(hour=0, minute=0, second=0, microsecond=0) to have a rolling 2 hour window.

Thank you! So this is correct?

  - platform: history_stats
    name: Heating Ratio Two Hours
    entity_id: sensor.hvac_activity
    state: 'heating'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 2
1 Like