diff --git a/custom_components/zha_toolkit/_user.py b/custom_components/zha_toolkit/_user.py index 76ded8d..333a116 100644 --- a/custom_components/zha_toolkit/_user.py +++ b/custom_components/zha_toolkit/_user.py @@ -46,7 +46,7 @@ async def user_sinope_write_test( ieee = t.EUI64.deserialize(b"\xae\x09\x01\x00\x40\x91\x0b\x50")[0] - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) cluster = dev.endpoints[1].thermostat @@ -82,7 +82,7 @@ async def user_zigpy_deconz( LOGGER.debug("Getting model from iris: %s", service) ieee = t.EUI64(b"\x00\x0d\x6f\x00\x0f\x3a\xf6\xa6") - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) cluster = dev.endpoints[2].basic res = await cluster.read_attributes( @@ -99,7 +99,7 @@ async def user_tuya_magic( to try to get 'normal' behavior. """ - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) basic_cluster = dev.endpoints[1].in_clusters[0] # The magic spell is needed only once. diff --git a/custom_components/zha_toolkit/binds.py b/custom_components/zha_toolkit/binds.py index dd01199..41629e3 100644 --- a/custom_components/zha_toolkit/binds.py +++ b/custom_components/zha_toolkit/binds.py @@ -29,7 +29,7 @@ async def bind_group( LOGGER.error("missing ieee") return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) # Get tries tries = params[p.TRIES] @@ -171,7 +171,7 @@ async def unbind_group( LOGGER.error("missing data (destination ieee)") return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) group_id = u.str2int(data) @@ -237,7 +237,7 @@ async def bind_ieee( if ieee is None: raise ValueError("'ieee' required") - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) if data in [0, False, "0", None]: # when command_data is set to 0 or false, bind to coordinator data = app.ieee @@ -428,7 +428,7 @@ async def binds_remove_all( if ieee is None: LOGGER.error("missing ieee") return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) zdo = src_dev.zdo # Get target ieee filter @@ -581,7 +581,7 @@ async def binds_get( if ieee is None: LOGGER.error("missing ieee") return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) zdo = src_dev.zdo # Get tries diff --git a/custom_components/zha_toolkit/groups.py b/custom_components/zha_toolkit/groups.py index 91d7114..f70117e 100644 --- a/custom_components/zha_toolkit/groups.py +++ b/custom_components/zha_toolkit/groups.py @@ -16,7 +16,7 @@ async def get_groups( LOGGER.error("missing ieee") return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) groups: dict[int, dict[str, Any]] = {} endpoint_id = params[p.EP_ID] @@ -65,7 +65,7 @@ async def add_group( if ieee is None or not data: raise ValueError("ieee and command_data required") - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) group_id = u.str2int(data) endpoint_id = params[p.EP_ID] @@ -104,7 +104,7 @@ async def remove_group( if ieee is None or not data: raise ValueError("ieee and command_data required") - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) group_id = u.str2int(data) endpoint_id = params[p.EP_ID] @@ -139,7 +139,7 @@ async def remove_all_groups( if ieee is None: return - src_dev = u.get_device(app, listener, ieee) + src_dev = await u.get_device(app, listener, ieee) endpoint_id = params[p.EP_ID] result = [] @@ -165,7 +165,7 @@ async def add_to_group( LOGGER.error("invalid arguments for subscribe_group()") return - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) grp_id = u.str2int(data) endpoint_id = params[p.EP_ID] @@ -194,7 +194,7 @@ async def remove_from_group( if data is None or ieee is None: raise ValueError("ieee and command_data required") - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) grp_id = u.str2int(data) endpoint_id = params[p.EP_ID] @@ -228,7 +228,7 @@ async def get_zll_groups( LOGGER.error("missing ieee") return - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) clusters = [ ep.in_clusters[LightLink.cluster_id] diff --git a/custom_components/zha_toolkit/neighbours.py b/custom_components/zha_toolkit/neighbours.py index 3bbf78a..1e8cfc2 100644 --- a/custom_components/zha_toolkit/neighbours.py +++ b/custom_components/zha_toolkit/neighbours.py @@ -22,7 +22,7 @@ async def get_routes_and_neighbours( return LOGGER.debug("Getting routes and neighbours: %s", service) - device = u.get_device(app, listener, ieee) + device = await u.get_device(app, listener, ieee) event_data["result"] = await _routes_and_neighbours(device, listener) ieee_tail = "".join([f"{o:02X}" for o in device.ieee]) diff --git a/custom_components/zha_toolkit/ota.py b/custom_components/zha_toolkit/ota.py index ffec6d0..9fae296 100644 --- a/custom_components/zha_toolkit/ota.py +++ b/custom_components/zha_toolkit/ota.py @@ -217,7 +217,7 @@ async def ota_notify( LOGGER.debug("running 'image_notify' command: %s", service) - device = u.get_device(app, listener, ieee) + device = await u.get_device(app, listener, ieee) cluster = None for epid, ep in device.endpoints.items(): diff --git a/custom_components/zha_toolkit/scan_device.py b/custom_components/zha_toolkit/scan_device.py index f5a0a66..b08fa2d 100644 --- a/custom_components/zha_toolkit/scan_device.py +++ b/custom_components/zha_toolkit/scan_device.py @@ -427,7 +427,7 @@ async def scan_device( LOGGER.debug("Running 'scan_device'") - device = u.get_device(app, listener, ieee) + device = await u.get_device(app, listener, ieee) endpoints = params[p.EP_ID] manf = params[p.MANF] diff --git a/custom_components/zha_toolkit/tuya.py b/custom_components/zha_toolkit/tuya.py index 5c567f1..30cf5c3 100644 --- a/custom_components/zha_toolkit/tuya.py +++ b/custom_components/zha_toolkit/tuya.py @@ -9,7 +9,7 @@ async def tuya_magic( Send 'magic spell' sequence to device to try to get 'normal' behavior. """ - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) basic_cluster = dev.endpoints[1].in_clusters[0] # The magic spell is needed only once. diff --git a/custom_components/zha_toolkit/zcl_cmd.py b/custom_components/zha_toolkit/zcl_cmd.py index 64b1885..a9bc28d 100644 --- a/custom_components/zha_toolkit/zcl_cmd.py +++ b/custom_components/zha_toolkit/zcl_cmd.py @@ -24,7 +24,7 @@ async def zcl_cmd(app, listener, ieee, cmd, data, service, params, event_data): LOGGER.error(msg) raise Exception(msg) - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) # The next line will also update the endpoint if it is not set cluster = u.get_cluster_from_params(dev, params, event_data) diff --git a/custom_components/zha_toolkit/zdo.py b/custom_components/zha_toolkit/zdo.py index 7e14c59..9532143 100644 --- a/custom_components/zha_toolkit/zdo.py +++ b/custom_components/zha_toolkit/zdo.py @@ -53,7 +53,7 @@ async def ieee_ping( return # The device is the parent device - dev = u.get_device(app, listener, ieee) + dev = await u.get_device(app, listener, ieee) # Get tries tries = params[p.TRIES] @@ -154,7 +154,7 @@ async def zdo_flood_parent_annce( async def _flood_with_parent_annce(app, listener): - coord = u.get_device(app, listener, app.ieee) + coord = await u.get_device(app, listener, app.ieee) while True: children = [