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

This commit is contained in:
Erik Montnemery
2021-09-27 12:17:09 +02:00
committed by GitHub
parent 931cf4eaab
commit 58f465f271
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])),
},
]
}