Guard for missing value (#45867)

* guard for missing value

* update comment
This commit is contained in:
Marcel van der Veldt 2021-02-02 19:57:08 +01:00 committed by GitHub
parent c93fec34b3
commit 2e98cfb9ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,7 +92,13 @@ class ZWaveBaseEntity(Entity):
@property @property
def available(self) -> bool: def available(self) -> bool:
"""Return entity availability.""" """Return entity availability."""
return self.client.connected and bool(self.info.node.ready) return (
self.client.connected
and bool(self.info.node.ready)
# a None value indicates something wrong with the device,
# or the value is simply not yet there (it will arrive later).
and self.info.primary_value.value is not None
)
@callback @callback
def _value_changed(self, event_data: dict) -> None: def _value_changed(self, event_data: dict) -> None: