Misc. ZHA changes (#23190)
* handle the off part of on with timed off command * use correct var * only bind / configure cluster once * clean up channel configuration * additional debug logging * add guard * prevent multiple discoveries for a device * cleanup and still configure on rejoin
This commit is contained in:
parent
5e1338a9e4
commit
38d23ba0af
4 changed files with 99 additions and 25 deletions
|
@ -259,17 +259,25 @@ class ZHAGateway:
|
|||
"""Handle device joined and basic information discovered (async)."""
|
||||
zha_device = self._async_get_or_create_device(device, is_new_join)
|
||||
|
||||
discovery_infos = []
|
||||
for endpoint_id, endpoint in device.endpoints.items():
|
||||
async_process_endpoint(
|
||||
self._hass, self._config, endpoint_id, endpoint,
|
||||
discovery_infos, device, zha_device, is_new_join
|
||||
is_rejoin = False
|
||||
if zha_device.status is not DeviceStatus.INITIALIZED:
|
||||
discovery_infos = []
|
||||
for endpoint_id, endpoint in device.endpoints.items():
|
||||
async_process_endpoint(
|
||||
self._hass, self._config, endpoint_id, endpoint,
|
||||
discovery_infos, device, zha_device, is_new_join
|
||||
)
|
||||
if endpoint_id != 0:
|
||||
for cluster in endpoint.in_clusters.values():
|
||||
cluster.bind_only = False
|
||||
for cluster in endpoint.out_clusters.values():
|
||||
cluster.bind_only = True
|
||||
else:
|
||||
is_rejoin = is_new_join is True
|
||||
_LOGGER.debug(
|
||||
'skipping discovery for previously discovered device: %s',
|
||||
"{} - is rejoin: {}".format(zha_device.ieee, is_rejoin)
|
||||
)
|
||||
if endpoint_id != 0:
|
||||
for cluster in endpoint.in_clusters.values():
|
||||
cluster.bind_only = False
|
||||
for cluster in endpoint.out_clusters.values():
|
||||
cluster.bind_only = True
|
||||
|
||||
if is_new_join:
|
||||
# configure the device
|
||||
|
@ -290,15 +298,16 @@ class ZHAGateway:
|
|||
else:
|
||||
await zha_device.async_initialize(from_cache=True)
|
||||
|
||||
for discovery_info in discovery_infos:
|
||||
async_dispatch_discovery_info(
|
||||
self._hass,
|
||||
is_new_join,
|
||||
discovery_info
|
||||
)
|
||||
if not is_rejoin:
|
||||
for discovery_info in discovery_infos:
|
||||
async_dispatch_discovery_info(
|
||||
self._hass,
|
||||
is_new_join,
|
||||
discovery_info
|
||||
)
|
||||
|
||||
device_entity = async_create_device_entity(zha_device)
|
||||
await self._component.async_add_entities([device_entity])
|
||||
device_entity = async_create_device_entity(zha_device)
|
||||
await self._component.async_add_entities([device_entity])
|
||||
|
||||
if is_new_join:
|
||||
device_info = async_get_device_info(self._hass, zha_device)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue