Fix KeyError error when fetching sensors (Airthings) (#115844)
This commit is contained in:
parent
fced9eb4b5
commit
d367bc63f0
1 changed files with 8 additions and 0 deletions
|
@ -157,3 +157,11 @@ class AirthingsHeaterEnergySensor(
|
|||
def native_value(self) -> StateType:
|
||||
"""Return the value reported by the sensor."""
|
||||
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…
Add table
Reference in a new issue