#Graphing hours heating/cooling

1 messages · Page 1 of 1 (latest)

sharp river
#

Hello,

I have a template and a couple sensors that tracks how long my hvac heats/cools each day. The sensors work perfectly, they ready the right amounts and tick up just fine. When I try to graph these sensors I run into a weird issue, if on Monday I cool for 8 hours and in Tuesday I cool for 9 everything works fine and the correct values are displayed. If I cool for 9 hours on Monday and 8 on Tuesday, it’s like the graph is seeing that 9 hours from Monday on the midnight between the 2 days and then says that I cooled for 9 on both days which is incorrect.

urban turtle
#

How have you setup the sensors. Sounds like an issue with using daily max value.

#

And how is your graph setup.

sharp river
#

@urban turtle the graph is a bar graph with period set to day, and stat type set to max

#

template:

  • sensor:
    • name: "Thermostat State"
      state: "{{ state_attr('climate.tstat_ec199d_t5_thermostat', 'hvac_action') }}"

sensor:

  • platform: history_stats
    name: "Heating Hours Today"
    entity_id: sensor.thermostat_state
    state: "heating"
    type: time
    start: "{{ now().replace(hour=0, minute=5, second=0) }}"
    end: "{{ now() }}"
  • platform: history_stats
    name: "Cooling Hours Today"
    entity_id: sensor.thermostat_state
    state: "cooling"
    type: time
    start: "{{ now().replace(hour=0, minute=5, second=0) }}"
    end: "{{ now() }}"
urban turtle
#

Yeah that's going to be problematic, because history stats only updates once per minute, so when 12:00:00AM rolls around, it history stats will still have yesterday's accumulated value. At 12:00:01 or so it will reset to 0, but by then the statistics will count the value at 12:00:00 as today's value.

#

If you want to take the max of an accumulating value, you really need to reset the value to 0 before 12:00:00AM

sharp river
#

So the start would need to be before

urban turtle
#

Something like this can work I think:

start: "{{ now() if now() > today_at("23:59") else today_at() }}"
end: "{{ now() }}"
sharp river
#

I’m currently away from home and editing it through the app is a pain, but I will implement this when I get home

urban turtle
#

So for all day before 23:59, start is 00:00 and end is now().
Then at 23:59, start and end are both now(), so the count will reset to 0.

#

Or you can not use history stats at all, and use a template, riemann sum, and a utility meter, is another way to do it.

sharp river
#

Hmmm that’s an idea, if the other method doesn’t work I’ll use a Riemann sum

#

I’m doing something similar for a ups to get electricity usage from it

sharp river
#

I finally got around to implementing this, I’ll let you know how it works in a few days

sharp river
#

For some reason in July 8th this completely broke, my thermostat state template forever says off now

#

Fixed it, somehow when I last rewrote it I converted it to a binary sensor instead of a sensor my bad