2.6 KiB
title, description, ha_category, ha_iot_class, ha_release, ha_quality_scale, ha_codeowners, ha_domain, ha_platforms
title | description | ha_category | ha_iot_class | ha_release | ha_quality_scale | ha_codeowners | ha_domain | ha_platforms | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Statistics | Instructions on how to integrate statistical sensors into Home Assistant. |
|
Local Polling | 0.30 | internal |
|
statistics |
|
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 the source is a binary sensor then only state changes are counted.
Assuming the recorder
integration is running (either configured explicitly or as part of a meta-integration/dependency, e.g., default_config
, history
, etc.), historical sensor data is read from the database on startup and is available immediately after a restart of the platform. If the recorder
integration is not running, it can take time for the sensor to start reporting data because some attribute calculations require more than one value.
Configuration
To enable the statistics sensor, add the following lines to your configuration.yaml
:
# enable the recorder integration (optional)
recorder:
# Example configuration.yaml entry
sensor:
- platform: statistics
entity_id: sensor.cpu
- platform: statistics
entity_id: binary_sensor.movement
max_age:
minutes: 30
{% configuration %} entity_id: description: The entity to monitor. Only sensors and binary sensor. required: true type: string name: description: Name of the sensor to use in the frontend. required: false default: Stats type: string sampling_size: description: Size of the sampling. If the limit is reached then the values are rotated. required: false default: 20 type: integer max_age: description: 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. required: false type: time precision: description: Defines the precision of the calculated values, through the argument of round(). required: false default: 2 type: integer {% endconfiguration %}