Min/Max integration always equal my current sensor value?

I added the min/max integration then created two helper entities:

But the min and max sensors always contain the current sensor value:

Do I not understand the integration, or did I set it up wrong?

Based on your naming convention, it seems you assumed this would give you the minimum or maximum value over a time period? The Min/Max integration gives you the min or max value from a series of sensors at the current time.

If you want the min or max value on a single sensor over a time period, use statistics

1 Like

Ah! Got it. (I think). So if I have temperature sensors all over my garden I can use min/max to get the hottest and coolest temperatures over all of the listed sensors. One value, multiple sensors.

I will look at Statistics.

Yes, for statistics, use value_min for the state_characteristic

Statistics worked great. For the benefit of any future search for a similar solution:

In my sensors.yaml file:

  - platform: statistics
    name: "Freezer min"  
    entity_id: sensor.freezer_temperature_c
    state_characteristic: value_min
    max_age:
      hours: 24
    
  - platform: statistics
    name: "Freezer max"  
    entity_id: sensor.freezer_temperature_c
    state_characteristic: value_max
    max_age:
      hours: 24

You will only average 20 samples in 24 hours. You may want more than this (I would consider 100 as the sample size if you get a reading every 15 minutes)

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.

I am doing:

dallas:
  - pin: D4
    update_interval: 5.0s

This should be a lot more than 20 samples, shouldn’t it?

Thanks for the tip. I went back to the docs and now understand that my update_interval is not related to the sample_size.

@ AllHailJJ Gent
Can you help me understand why my min-max is only reporting the past few hours (The highlighted range in the image). Is my sample size too small?

Thanks.

The last high of -5.5 °C was at 12:02, and the last reading was at 9:21 AM. Not even 12 hours.

Here is my sensor component in configuration.yaml:

#Freezer minimum and maximum temperatures      
  - platform: statistics
    name: "Freezer min"  
    entity_id: sensor.freezer_temperature_c
    state_characteristic: value_min
    sampling_size: 100
    max_age:
      hours: 24
    
  - platform: statistics
    name: "Freezer max"  
    entity_id: sensor.freezer_temperature_c
    state_characteristic: value_max
    sampling_size: 100
    max_age:
      hours: 24

because your sample size is too small. You said your update interval is every 5 seconds. There is 24 * 60 * 60 seconds in a day. Divide that by 5 and that’s 86400/5, exactly 17280 samples.

1 Like

Thanks. I thought so after writing my post. I bumped t to 20,00 and now I have the data I wanted. Am I correct that this just reads the data already stored in the database?

Yep, that’s all it does