mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Fix KeyError error when fetching sensors (Airthings) (#115844)
This commit is contained in:
parent
fced9eb4b5
commit
d367bc63f0
@ -157,3 +157,11 @@ class AirthingsHeaterEnergySensor(
|
|||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the value reported by the sensor."""
|
"""Return the value reported by the sensor."""
|
||||||
return self.coordinator.data[self._id].sensors[self.entity_description.key] # type: ignore[no-any-return]
|
return self.coordinator.data[self._id].sensors[self.entity_description.key] # type: ignore[no-any-return]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Check if device and sensor is available in data."""
|
||||||
|
return (
|
||||||
|
super().available
|
||||||
|
and self.entity_description.key in self.coordinator.data[self._id].sensors
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user