1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

fix derived rate, fixes #20097 (#21620)

* fix derived rate, fixes #20097

* fix derived rate, fixes #20097

* Fix typo

thnx @amelchio

* Make the test more realistic

Took values from my own smart meter for the test

* Update test to ignore rounding issues
This commit is contained in:
Willem Burgers
2019-03-03 23:42:52 +01:00
committed by Anders Melchiorsen
parent 818776d2b4
commit 2017e45d78
2 changed files with 8 additions and 7 deletions

View File

@@ -350,7 +350,8 @@ class DerivativeDSMREntity(DSMREntity):
else:
# Recalculate the rate
diff = current_reading - self._previous_reading
self._state = diff
timediff = timestamp - self._previous_timestamp
self._state = diff / timediff * 3600
self._previous_reading = current_reading
self._previous_timestamp = timestamp