I might be overlooking something obvious, but I just cannot understand this issue I am experiencing with the statistics integration.
I have a simple counter, which tracks the number of heating cycles of my heat pump.
I now want to derive the number of heating cycles over the past 24h. This should be a simple max - min calculation, ie 7424 - 7417 = 7. But HA gives me 6!?
I have tried statistics change, I have tried statistics distance_absolute, both give me 6. (See my sensor configuration below).
I then looked at min and max values, and the underlying issue seems to be that the min value returned is 7418, rather than 7417.
I also tried adding keep_last_sample: true
(I have to admit, from the docs I still do not full understand what it does), but that made no difference.
Can anybody help me wrap my head around this?
- platform: statistics
name: "WP Heizzyklen 24h"
entity_id: sensor.cycles_waermepumpe
unique_id: heizzyklen_waermepumpe_flamme
state_characteristic: change
max_age:
hours: 24
precision: 0
- platform: statistics
name: "WP Heizzyklen 24h (Distance)"
entity_id: sensor.cycles_waermepumpe
unique_id: heizzyklen_waermepumpe_flamme_2
state_characteristic: distance_absolute
max_age:
hours: 24
precision: 0
- platform: statistics
name: "WP Heizzyklen 24h (Max)"
entity_id: sensor.cycles_waermepumpe
unique_id: heizzyklen_waermepumpe_flamme_max
state_characteristic: value_max
keep_last_sample: true
max_age:
hours: 24
precision: 0
- platform: statistics
name: "WP Heizzyklen 24h (Min)"
entity_id: sensor.cycles_waermepumpe
unique_id: heizzyklen_waermepumpe_flamme_min
state_characteristic: value_min
keep_last_sample: true
max_age:
hours: 24
precision: 0