Been struggling with this one for a while now. I’d like to create a simple bar chart showing the past 12 months, and for each month 2 bars: one for total cooling runtime, and total heating runtime. I manage to do that fine for the current month/day, but what’s tripping me up is trying to get the history for past months, would appreciate any pointers, thanks!
You’ll need to get a sensor into long term statistics to make this work. I recommend:
-
Make a template sensor (one per heating and one per cooling), that is ‘1’ when it is on and ‘0’ when it is off.
-
Make a method:
left
, time:hours
, riemann sum of each 1/0 sensor. The value of this sensor will be the lifetime number of hours the hvac was heating or cooling, since the sensor was created.
Then you can make a statistics graph card of the monthly change of this sensor, which will be the number of hours it ran for that month. The values will stay in your long term database forever.
Thanks, I think I did manage to get it to work with utility meters, but I’ll look into your approach too to see if it’s better. Here’s my chart right now:
type: statistics-graph
title: HVAC Runtime by Month (last 12 months)
chart_type: bar
period: month
days_to_show: 365
entities:
- sensor.heating_monthly
- sensor.cooling_monthly
stat_types:
- state
Now I’m also trying to see about making the graph so that it will show the value for the same month the previous year (so basically a chart with the 12 month of the year on X and for each month one bar for cooling total last year, and one bar for this year). Everything lead I found so far is either very hacky and/or not worth the effort so I might have to forget about that…