Fix broken upnp derived sensors reporting b/s instead of kb/s (#57681)

This commit is contained in:
Steven Looman 2021-10-15 22:03:03 +02:00 committed by GitHub
parent 12d1dfdaf9
commit b75f1b8951
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 191 additions and 10 deletions

View file

@ -190,7 +190,10 @@ class DerivedUpnpSensor(UpnpSensor):
# Calculate derivative.
delta_value = current_value - self._last_value
if self.entity_description.native_unit_of_measurement == DATA_BYTES:
if (
self.entity_description.native_unit_of_measurement
== DATA_RATE_KIBIBYTES_PER_SECOND
):
delta_value /= KIBIBYTE
delta_time = current_timestamp - self._last_timestamp
if delta_time.total_seconds() == 0: