Speed up OZW availability check (#38758)

* Speed up OZW availability check

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/38768/head
Paulus Schoutsen 2020-08-11 18:23:10 +02:00 committed by GitHub
parent 016cd8f8ef
commit f31a580caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -25,6 +25,7 @@ from .const import DOMAIN, PLATFORMS
from .discovery import check_node_schema, check_value_schema
_LOGGER = logging.getLogger(__name__)
OZW_READY_STATES_VALUES = {st.value for st in OZW_READY_STATES}
class ZWaveDeviceEntityValues:
@ -224,9 +225,7 @@ class ZWaveDeviceEntity(Entity):
"""Return entity availability."""
# Use OZW Daemon status for availability.
instance_status = self.values.primary.ozw_instance.get_status()
return instance_status and instance_status.status in (
state.value for state in OZW_READY_STATES
)
return instance_status and instance_status.status in OZW_READY_STATES_VALUES
@callback
def _value_changed(self, value):