|
12 | 12 | import zigpy.profiles
|
13 | 13 | import zigpy.zcl.foundation
|
14 | 14 |
|
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 |
16 | 16 |
|
17 | 17 | from zigpy.zcl import clusters
|
18 | 18 | from zigpy.types import ExtendedPanId, deserialize as list_deserialize
|
@@ -154,7 +154,19 @@ def _receive_zdo_message(
|
154 | 154 | field_names, field_types = ZDO_CLUSTERS[cluster]
|
155 | 155 | assert set(zdo_kwargs) == set(field_names)
|
156 | 156 |
|
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 | + |
158 | 170 | message = t.serialize_list([t.uint8_t(tsn)] + zdo_args)
|
159 | 171 |
|
160 | 172 | LOGGER.trace("Pretending we received a ZDO message: %s", message)
|
|
0 commit comments