From 9cddbc90e9fd38fafce46796abcc367133542f80 Mon Sep 17 00:00:00 2001 From: David Mulcahey Date: Thu, 14 Feb 2019 10:27:44 -0500 Subject: [PATCH 1/2] set availability on device join --- homeassistant/components/zha/core/gateway.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index 02ed1d736991ab..ff3c374a850940 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -164,6 +164,9 @@ async def async_device_initialized(self, device, is_new_join): device_entity = _create_device_entity(zha_device) await self._component.async_add_entities([device_entity]) + if is_new_join: + zha_device.update_available(True) + async def _async_process_endpoint( self, endpoint_id, endpoint, discovery_infos, device, zha_device, is_new_join): From 9c5638d37e83aaa6c8a83dda8bcc3d504b5a3c95 Mon Sep 17 00:00:00 2001 From: David Mulcahey Date: Fri, 15 Feb 2019 10:31:03 -0500 Subject: [PATCH 2/2] fix new join test --- tests/components/zha/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/components/zha/common.py b/tests/components/zha/common.py index 1a923849ce531d..f0e1aa701e766f 100644 --- a/tests/components/zha/common.py +++ b/tests/components/zha/common.py @@ -1,7 +1,6 @@ """Common test objects.""" import time from unittest.mock import patch, Mock -from homeassistant.const import STATE_UNAVAILABLE from homeassistant.components.zha.core.helpers import convert_ieee from homeassistant.components.zha.core.const import ( DATA_ZHA, DATA_ZHA_CONFIG, DATA_ZHA_DISPATCHERS, DATA_ZHA_BRIDGE_ID @@ -191,4 +190,4 @@ async def async_test_device_join( cluster = zigpy_device.endpoints.get(1).in_clusters[cluster_id] entity_id = make_entity_id( domain, zigpy_device, cluster, use_suffix=device_type is None) - assert hass.states.get(entity_id).state == STATE_UNAVAILABLE + assert hass.states.get(entity_id) is not None