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 GitHub
parent dd216ac15b
commit a53997dfc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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]