Thermostat Duty Cycle

I am trying to create a sensor that tells me the “duty cycle” of my HVAC system as reported by my thermostat for the past hour. I tried using the following for the sensor:

  - platform: history_stats
    name: HVAC duty cycle
    entity_id: sensor.hvac_operating_state
    state:
      - "heating"
      - "cooling"
    type: "ratio"
    end: "{{ now() }}"
    duration:
      hours: 1

While this does seem to give me some measure of duty cycle I don’t think it is accurately reporting the duty cycle for the previous hour. I can see it has an attribute “value” that typically fluctuates between 30m-59m. I am guessing that is the actual time range it is calculating duty cycle for. My theory is that it starts the time range at the first state change within the duration specified in the configuration. Does anyone know if my theories are plausible and if there is any way to work around those issues? Is there a better way I should be going about this?

This works for me:

  - platform: history_stats
    name: Heat ON duty cycle 
    entity_id: switch.heating
    state: 'on'
    type: ratio
    end: '{{ now() }}' 
    duration: 
      hours: 24

Im using a switch instead of a state because of my homebrew thermostat.
Maybe try a single state. I have another duty cycle monitor for my well but using esphome to calculate it on a 5min duration.

2 Likes

So it looks like that value attribute is actually likely the amount of time the entity spent in the “active” state, so I feel a little silly for not realizing that sooner. It still seemed like I was getting some unexpected values from the sensor though, I’ll have to take a closer look at the data and see if I can find examples.