From e4667498374391ffd856fb24c366ba5ac698077e Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 22 Dec 2021 08:44:38 +0100 Subject: [PATCH] Clarify energy sensor statistics calculation (#1165) --- docs/core/entity/sensor.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/core/entity/sensor.md b/docs/core/entity/sensor.md index 7a11053e..e10bedbe 100644 --- a/docs/core/entity/sensor.md +++ b/docs/core/entity/sensor.md @@ -103,6 +103,10 @@ zero-point. When `last_reset` changes, the zero-point will be set to 0. If last_reset is not set, the sensor's value when it was first added is used as the zero-point when calculating `sum` statistics. +To put it in another way: the logic when updating the statistics is to update +the sum column with the difference between the current state and the previous state +unless `last_reset` has been changed, in which case don't add anything. + Example of state class `total` without last_reset: | t | state | sum | sum_increase | sum_decrease | @@ -145,6 +149,10 @@ cycle. This state class is useful for gas meters, electricity meters, water mete The value when the sensor reading decreases will not be used as zero-point when calculating `sum` statistics, instead the zero-point will be set to 0. +To put it in another way: the logic when updating the statistics is to update +the sum column with the difference between the current state and the previous state +unless the difference is negative, in which case don't add anything. + Example of state class `total_increasing`: | t | state | sum |