Skip to content

Sensor min max value

Max Chodorowski edited this page Dec 11, 2020 · 1 revision

The best way to track min/max value is via statistics sensor. It provides a standard set of statistical values for given sensor (keep in mind that it has to be stored via recorder).

- platform: statistics
  name: Outside temp stats
  entity_id: sensor.thermometer_outside_temperature
  sampling_size: 1440
  max_age:
    days: 1

The max_age defines a lookup / time window for which the values should be calculated.

It is good to adjust the sampling_size as the default value is 20. The best way to calculate this value is to take number of seconds in your time window (max_age) and divide by the frequency how often your sensor updates (to not miss any spikes - as long you are interested). For example the temperature at home or outside doesn't change very often so using 60s as an update interval is more than enough.

In 1 day we have 84600 seconds so sampling size calculation should be as follows

84600 / 60 = 1440

Pretty convenient way of displaying the results is to use multi-entity-row card. This way you can put all of them in the single line in entities card:

image

type: entities
entities:
  - type: custom:multiple-entity-row
    entity: sensor.outside_temp
    entities:
      - entity: sensor.outside_temp_stats
        attribute: min_value
        name: min
      - entity: sensor.outside_temp_stats
        attribute: max_value
        name: max

Clone this wiki locally