Graceful handling of missing datapoint in myuplink (#146517)

This commit is contained in:
Åke Strandberg 2025-06-11 11:55:28 +02:00 committed by Franck Nijhof
parent 6d1f621e55
commit c8b70cc0fb
No known key found for this signature in database
GPG Key ID: AB33ADACE7101952

View File

@ -293,8 +293,8 @@ class MyUplinkDevicePointSensor(MyUplinkEntity, SensorEntity):
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType:
"""Sensor state value.""" """Sensor state value."""
device_point = self.coordinator.data.points[self.device_id][self.point_id] device_point = self.coordinator.data.points[self.device_id].get(self.point_id)
if device_point.value == MARKER_FOR_UNKNOWN_VALUE: if device_point is None or device_point.value == MARKER_FOR_UNKNOWN_VALUE:
return None return None
return device_point.value # type: ignore[no-any-return] return device_point.value # type: ignore[no-any-return]