Really struggling to plot a column chart for the amount of minutes my heating is on in hourly intervals (over a 24 hour period).
To simulate this, ive created a template binary sensor which has an “on” and “off” state, triggered by the thermostat being set to 16 or below. (This binary sensor would be replaced by looking at whether the thermostat was “idle” or “heating”).
nest_upstairs_setpoint_below_16:
value_template: >
{% if states('sensor.nest_upstairs_setpoint') is defined and
int(states('sensor.nest_upstairs_setpoint')) <= 16 %}
on
{% else %}
off
{% endif %}
The sensor tracks on/off states:
This is what I am using in my chart template:
type: custom:apexcharts-card
graph_span: 24h
header:
show: true
title: Nest Upstairs Heating
update_interval: 60min
span:
start: day
series:
- entity: sensor.nest_upstairs_setpoint_below_16
type: column
transform: |
return x === 'on' ? 1 : 0;
stroke_width: 2
color: red
opacity: 1
group_by:
fill: last
func: sum
duration: 60m
I am not seeing the values as a sum of the on state in a 1 hour period. Eg. Between 10am and 11am, I’d expect to see a line showing 45 minutes duration:
(I cant post more than one image unfortunately, so included this one to show the yellow “on” period i am trying to chart with a value of 45 minutes).
Instead, I get a value of “1” for 10am and a maximum value of “4” at 11am.
Im obviously doing something completely wrong, so any pointers appreciated!