I have the following statistics sensor configured:
- platform: statistics
name: kostprijs_elektriciteit_gemiddeld_maand
state_characteristic: mean
sampling_size: 60
entity_id: sensor.average_electricity_price_today
max_age:
days: 30
The goal is to calculate the mean value of the electricity price over an entire month.
The problem is that somehow the statistics sensor updates every 5 minutes, but the sensor value only changes once, or twice a day. Resulting in the wrong mean value.
For example: previous value was 10, then it changes to 12, so the mean value must be 11.
However since it updates every 5 minutes this results in:
10 + 12 + 12 + 12 + 12 after 20 minutes, giving me 11,6 which is wrong.
I’ve tried several configurations, leaving out sampling size, only providing sampling size, changing state_characteristic to average_timeless … no avail.
Question is: is this even possible with the statistics sensor or should I do this with an automation which updates an input_number every 24 hours?
Preferably I would like to use the statistics sensor.