HVAC Runtime code

I’m on the HA struggle bus. I found tons of examples of how to track my HVAC (pellet stove) runtime. But I cannot figure out where to put the code!? When I add the code to configuration.yaml, I get all kinds of errors. Basically the code below is what I need, I just don’t know where to put it. Please help.

  • platform: template
    sensors:
    pelletstoveruntime:
    friendly_name: Pellet Stove Runtime Today
    icon_template: mdi:radiator
    value_template: “{{ state_attr(‘climate.pellet_stove’ , ‘hvac_action’ )}}”

  • platform: history_stats
    name: “Pellet Stove Runtime”
    entity_id: sensor.pelletstoveruntime
    state: “heating”
    type: time
    end: “{{ now() }}”
    duration:
    hours: 24

Both of those can be set up in the UI through the Helpers menu.

If you just want to add them in YAML, then they need to be under the top-level key sensor. Though you may want to address the naming… you’re going to end up with a sensor.pelletstoveruntime and a sensor.pellet_stove_runtime

You would need to provide the sensor configurations properly formatted for us to tell if there is something else that needs to be addressed.

I’m still struggling. I setup a Helper to count the number of times my stove turns on per day… Then added an automation to reset the counter back to Zero at midnight. Works great.

But what I cannot figure out is how to calculate the runtime in minutes the stove has run since Midnight. Can someone please help me out?

Ultimate I just want a simple card that shows me How many times the stove turned on, and for how many minutes in ran since Midnight…and for both values to reset at midnight.

Did you set up the template sensor to track hvac_action?

If you have that sensor, you can create 2 history_stats sensors to get the desired information. By using {{ today_at() }} for the start the value will reset at midnight.

sensor:
  - platform: history_stats
    name: "Pellet Stove Runtime"
    entity_id: sensor.pelletstoveruntime
    state: "heating"
    type: time
    start: "{{ today_at() }}"
    duration:
      hours: 24

  - platform: history_stats
    name: "Pellet Stove Count"
    entity_id: sensor.pelletstoveruntime
    state: "heating"
    type: count
    start: "{{ today_at() }}"
    duration:
      hours: 24

As stated previously, these can also be created in the UI through the Helpers menu.

The “time” type defaults to hours as the unit, but once you have the sensor set up you can change that in the entity’s settings.

I do not have a template sensor to track hvac_action… And If I can set it up as a Help, it’s probably better… I’m not sure how to do that but will give it a try.

Go to Helpers
Click “Add Helper” at the bottom right.
Select Template > Template a sensor

Then all you need to do is give it a name and add the template you have above in the “State template” field. Leave all the other fields blank, they do not apply to this type of sensor.

It should look something like this...

Then you set up your History Stats sensors.

Again, go to Helpers and click “Add Helper” at the bottom right.

Select History Stats.

The "Time" type should look something like this...but with your Pellet Stove Action sensor in the Entity field

Click “Next” then setup the Start and Duration filed like:

Then do it again for the “Count” type sensor.

I will try this tonight! THANK YOU so much!

This was great, thank you!! One thing… If I create a history stats sensor… and I made a type-o in the “State” field… I typed heating instead of heat. How do I go back and edit that state? The GUI doesn’t seem to let me edit that part … All I can see/edit is the time??