I’m trying to build a sensor that will report the max power value from an esphome connected outlet over the past 24 hours.
I started with this:
- platform: statistics
name: "MasterTub Power Max"
entity_id: sensor.mastertub_power
state_characteristic: value_max
max_age:
hours: 24
Unfortunately, it did not hold the 24 hour max value of the sensor.mastertub_power. For some reason it was well under 24 hours. In the statistics documentation it says:
sampling_size integer (optional, default: 20)
Maximum number of source sensor measurements stored. Be sure to choose a reasonably high number if the limit should be driven by max_age
instead.
So I added, “sampling_size: 240” to the sensor. I have no idea what the sampling_size is in relation to time. I was assuming that it might be related to max_age, so I set it to sample 10 times an hour. This is what it looked like today:
So the power spike (caused by the jets being cleaned) started at 3:00 PM the previous day, but then the statistics sensor tossed this max value at around 7:30 AM the next day, obviously well inside a 24 hour window.
Am I wrong in thinking that finding a max and min over a set time period is unnecessarily convoluted here? In any case, it doesn’t work right, and no reading of the statistics documentation clears this up for me.