Allow ZHA coordinator binding/unbinding (#42854)

* Allow coordinator ZDO binding/unbinding operations

* Let coordinator to provide endpoint it

* Refactor ClusterPair to a dataclass

* Rename ClusterPair
This commit is contained in:
Alexei Chetroi 2020-11-06 17:33:13 -05:00 committed by GitHub
parent 121872c546
commit 4b7829d777
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 19 deletions

View file

@ -807,18 +807,12 @@ async def async_binding_operation(zha_gateway, source_ieee, target_ieee, operati
clusters_to_bind = await get_matched_clusters(source_device, target_device)
zdo = source_device.device.zdo
bind_tasks = []
for cluster_pair in clusters_to_bind:
destination_address = zdo_types.MultiAddress()
destination_address.addrmode = 3
destination_address.ieee = target_device.ieee
destination_address.endpoint = cluster_pair.target_cluster.endpoint.endpoint_id
zdo = cluster_pair.source_cluster.endpoint.device.zdo
for binding_pair in clusters_to_bind:
op_msg = "cluster: %s %s --> [%s]"
op_params = (
cluster_pair.source_cluster.cluster_id,
binding_pair.source_cluster.cluster_id,
operation.name,
target_ieee,
)
@ -829,9 +823,9 @@ async def async_binding_operation(zha_gateway, source_ieee, target_ieee, operati
zdo.request(
operation,
source_device.ieee,
cluster_pair.source_cluster.endpoint.endpoint_id,
cluster_pair.source_cluster.cluster_id,
destination_address,
binding_pair.source_cluster.endpoint.endpoint_id,
binding_pair.source_cluster.cluster_id,
binding_pair.destination_address,
),
op_msg,
op_params,