Make new cycles for sensor sum statistics start with 0 as zero-point (#55473)

This commit is contained in:
Erik Montnemery 2021-08-31 10:45:17 +02:00 committed by GitHub
parent 88a08fdf57
commit f9225bad5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View file

@ -403,11 +403,8 @@ def compile_statistics(
# ..and update the starting point
new_state = fstate
old_last_reset = last_reset
# Force a new cycle for STATE_CLASS_TOTAL_INCREASING to start at 0
if (
state_class == STATE_CLASS_TOTAL_INCREASING
and old_state is not None
):
# Force a new cycle for an existing sensor to start at 0
if old_state is not None:
old_state = 0.0
else:
old_state = new_state