Listen to node events in the zwave_js node status sensor (#55341)

This commit is contained in:
Raman Gupta 2021-08-27 18:01:20 -04:00 committed by GitHub
parent 1f37c215f6
commit 714564eaa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 6 deletions

View file

@ -462,6 +462,7 @@ class ZWaveNodeStatusSensor(SensorEntity):
"""Poll a value."""
raise ValueError("There is no value to poll for this entity")
@callback
def _status_changed(self, _: dict) -> None:
"""Call when status event is received."""
self._attr_native_value = self.node.status.name.lower()
@ -480,8 +481,3 @@ class ZWaveNodeStatusSensor(SensorEntity):
)
)
self.async_write_ha_state()
@property
def available(self) -> bool:
"""Return entity availability."""
return self.client.connected and bool(self.node.ready)