Don't reset meter when last_reset is set to None (#56609)

pull/56711/head
Erik Montnemery 2021-09-27 12:17:09 +02:00 committed by GitHub
parent 931cf4eaab
commit 58f465f271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -445,6 +445,7 @@ def compile_statistics( # noqa: C901
)
)
!= old_last_reset
and last_reset is not None
):
if old_state is None:
_LOGGER.info(

View File

@ -494,9 +494,9 @@ def test_compile_hourly_sum_statistics_amount_invalid_last_reset(
"min": None,
"last_reset": process_timestamp_to_utc_isoformat(dt_util.as_local(one)),
"state": approx(factor * seq[7]),
"sum": approx(factor * (sum(seq) - seq[0])),
"sum": approx(factor * (sum(seq) - seq[0] - seq[3])),
"sum_decrease": approx(factor * 0.0),
"sum_increase": approx(factor * (sum(seq) - seq[0])),
"sum_increase": approx(factor * (sum(seq) - seq[0] - seq[3])),
},
]
}