Fix rate of change calculation of statistics sensor (#32597)

* Fix rate of change of statistics sensor

* Fix test
This commit is contained in:
Florian Werner 2020-03-11 17:33:00 +01:00 committed by GitHub
parent 440c837eb6
commit 5216dc0ae1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -267,7 +267,7 @@ class StatisticsSensor(Entity):
time_diff = (self.max_age - self.min_age).total_seconds()
if time_diff > 0:
self.change_rate = self.average_change / time_diff
self.change_rate = self.change / time_diff
self.change = round(self.change, self._precision)
self.average_change = round(self.average_change, self._precision)