The statistics sensor platform consumes the state from other sensors. It exports the mean value as state and the following values as attributes: count, mean, median, stdev, variance, total, min_value, max_value, min_age, max_age, change, average_change and change_rate. If it’s a binary sensor then only state changes are counted.

If you are running the recorder component, on startup the data is read from the database. So after a restart of the platform, you will immediately have data available. If you’re using the history component, this will automatically also start the recorder integration on startup. If you are not running the recorder component, it can take time till the sensor starts to work because a couple of attributes need more than one value to do the calculation.


To enable the statistics sensor, add the following lines to your configuration.yaml:

# enable the recorder integration (optional)

# Example configuration.yaml entry
  - platform: statistics
    entity_id: sensor.cpu
  - platform: statistics
    entity_id: binary_sensor.movement
      minutes: 30

Configuration Variables

entity_id string Required

The entity to monitor. Only sensors and binary sensor.

name string (Optional, default: Stats)

Name of the sensor to use in the frontend.

sampling_size integer (Optional, default: 20)

Size of the sampling. If the limit is reached then the values are rotated.

max_age time (Optional)

Maximum age of measurements. Setting this to a time interval will cause older values to be discarded. Please note that you might have to increase the sampling_size parameter. If you e.g., have a sensor value updated every second you will, by default, only get a max_age of 20s.

precision integer (Optional, default: 2)

Defines the precision of the calculated values, through the argument of round().