Skip to content

Commit afad12c

Browse files
committed
Add temporary bugfix for zigpy/zigpy#434
1 parent c4d9554 commit afad12c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

zigpy_znp/zigbee/application.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import zigpy.profiles
1313
import zigpy.zcl.foundation
1414

15-
from zigpy.zdo.types import ZDOCmd, ZDOHeader, CLUSTERS as ZDO_CLUSTERS
15+
from zigpy.zdo.types import ZDOCmd, ZDOHeader, NodeDescriptor, CLUSTERS as ZDO_CLUSTERS
1616

1717
from zigpy.zcl import clusters
1818
from zigpy.types import ExtendedPanId, deserialize as list_deserialize
@@ -154,7 +154,19 @@ def _receive_zdo_message(
154154
field_names, field_types = ZDO_CLUSTERS[cluster]
155155
assert set(zdo_kwargs) == set(field_names)
156156

157-
zdo_args = [t(zdo_kwargs[n]) for n, t in zip(field_names, field_types)]
157+
# TODO: Remove this fix when https://github.com/zigpy/zigpy/pull/434 is merged
158+
zdo_args = []
159+
160+
for name, field_type in zip(field_names, field_types):
161+
zdo_arg = zdo_kwargs[name]
162+
163+
if issubclass(field_type, NodeDescriptor):
164+
# XXX: `t.Optional(NodeDescriptor).__init__` doesn't work well
165+
assert isinstance(zdo_arg, NodeDescriptor)
166+
zdo_args.append(zdo_arg)
167+
else:
168+
zdo_args.append(field_type(zdo_arg))
169+
158170
message = t.serialize_list([t.uint8_t(tsn)] + zdo_args)
159171

160172
LOGGER.trace("Pretending we received a ZDO message: %s", message)

0 commit comments

Comments
 (0)