Improve CO2Signal error handling (#53602)

* Improve CO2Signal error handling

* Update homeassistant/components/co2signal/sensor.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Paulus Schoutsen 2021-07-27 23:43:24 -07:00 committed by GitHub
parent d865577187
commit 9c33818392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,6 +114,13 @@ class CO2Sensor(update_coordinator.CoordinatorEntity[CO2SignalResponse], SensorE
f"{coordinator.entry_id}_{description.unique_id or description.key}"
)
@property
def available(self) -> bool:
"""Return True if entity is available."""
return (
super().available and self._description.key in self.coordinator.data["data"]
)
@property
def state(self) -> StateType:
"""Return sensor state."""