Min and max value for last 24h with variable sampling time

I want to display min and max value in 24h for outside sensor.
Is in this sensor min_age and max_age attribute depends on sampling_size ?
How to calculate sampling_size for last 24 hours ? This is zigbee sensor with variable sampling time.

- platform: statistics
  entity_id: sensor.outside
  name: "Outside stats"
  sampling_size: 500
  max_age:
    minutes: 1440

- platform: template
  sensors:
    outside_max:
      friendly_name: "outside max"
      value_template: "{{ state_attr('sensor.outside_stats', 'max_value') }}"
      unit_of_measurement: "°C"
    outside_min:
      friendly_name: "outside min"
      value_template: "{{ state_attr('sensor.outside_stats', 'min_value') }}"
      unit_of_measurement: "°C"
1 Like

Yes it is. If your sample size is too small you won’t cover the whole time period.

Sampling size = time period / sensor update interval. (+ 5% just to be sure).

So if your sensor updates every minute,

Sampling size = 24h*60 / 1 = 1440, call it 1500 to be safe.

You can check if you have enough by looking at the developer tools / states menu. The attributes for the sensor include a number of samples used. After 24 hours make sure this is less than the value you set.

1 Like