Skip to content

Commit

Permalink
#212 Fix several calls to get device from 'ieee' (bug introduced in v…
Browse files Browse the repository at this point in the history
…1.1.4)
  • Loading branch information
mdeweerd committed Nov 3, 2023
1 parent bc75c62 commit 579453e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions custom_components/zha_toolkit/_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions custom_components/zha_toolkit/binds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions custom_components/zha_toolkit/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 = []

Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/neighbours.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/ota.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/scan_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/zcl_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/zha_toolkit/zdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 579453e

Please sign in to comment.