Prevent upnp to use None values (#36803)

This commit is contained in:
Steven Looman 2020-06-23 01:39:57 +02:00 committed by GitHub
parent 247df5874b
commit d974cd4606
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -198,6 +198,8 @@ class RawUpnpSensor(UpnpSensor):
"""Return the state of the device."""
device_value_key = self._sensor_type["device_value_key"]
value = self._coordinator.data[device_value_key]
if value is None:
return None
return format(value, "d")
@ -235,6 +237,8 @@ class DerivedUpnpSensor(UpnpSensor):
# Can't calculate any derivative if we have only one value.
device_value_key = self._sensor_type["device_value_key"]
current_value = self._coordinator.data[device_value_key]
if current_value is None:
return None
current_timestamp = self._coordinator.data[TIMESTAMP]
if self._last_value is None or self._has_overflowed(current_value):
self._last_value = current_value