|
4 | 4 |
|
5 | 5 | import zigpy.application |
6 | 6 | import zigpy.exceptions |
| 7 | +import zigpy.device |
| 8 | +import zigpy.quirks |
7 | 9 | import zigpy.types |
8 | 10 | import zigpy.util |
9 | | -from zigpy.zdo.types import LogicalType |
| 11 | +from zigpy.zcl.clusters.general import Groups |
| 12 | +from zigpy.zdo.types import LogicalType, NodeDescriptor |
10 | 13 |
|
11 | 14 | from zigpy_xbee.types import UNKNOWN_IEEE |
12 | 15 |
|
|
19 | 22 | TIMEOUT_REPLY = 5 |
20 | 23 | TIMEOUT_REPLY_EXTENDED = 28 |
21 | 24 |
|
22 | | - |
23 | 25 | LOGGER = logging.getLogger(__name__) |
24 | 26 |
|
| 27 | +XBEE_ENDPOINT_ID = 0xe6 |
| 28 | + |
25 | 29 |
|
26 | 30 | class ControllerApplication(zigpy.application.ControllerApplication): |
27 | 31 | def __init__(self, api, database_file=None): |
@@ -80,7 +84,12 @@ async def startup(self, auto_form=False): |
80 | 84 | LOGGER.debug("Coordinator %s", 'enabled' if ce else 'disabled') |
81 | 85 | except RuntimeError as exc: |
82 | 86 | LOGGER.debug("sending CE command: %s", exc) |
83 | | - self.add_device(self.ieee, self.nwk) |
| 87 | + |
| 88 | + dev = zigpy.device.Device(self, self.ieee, self.nwk) |
| 89 | + dev.add_endpoint(XBEE_ENDPOINT_ID) |
| 90 | + self.listener_event('raw_device_initialized', dev) |
| 91 | + xbee_dev = XBeeCoordinator(self, self.ieee, self.nwk, dev) |
| 92 | + self.devices[dev.ieee] = xbee_dev |
84 | 93 |
|
85 | 94 | async def force_remove(self, dev): |
86 | 95 | """Forcibly remove device from NCP.""" |
@@ -196,7 +205,7 @@ def handle_rx(self, src_ieee, src_nwk, src_ep, dst_ep, cluster_id, profile_id, r |
196 | 205 | if src_nwk == 0: |
197 | 206 | # I'm not sure why we've started seeing ZDO requests from ourself. |
198 | 207 | # Ignore for now. |
199 | | - return |
| 208 | + LOGGER.info("handle_rx self addressed") |
200 | 209 |
|
201 | 210 | ember_ieee = zigpy.types.EUI64(src_ieee) |
202 | 211 | if dst_ep == 0 and cluster_id == 0x13: |
@@ -282,3 +291,35 @@ async def broadcast(self, profile, cluster, src_ep, dst_ep, grpid, radius, |
282 | 291 | data, |
283 | 292 | ) |
284 | 293 | return await asyncio.wait_for(request, timeout=TIMEOUT_TX_STATUS) |
| 294 | + |
| 295 | + |
| 296 | +class XBeeCoordinator(zigpy.quirks.CustomDevice): |
| 297 | + class XBeeGroup(zigpy.quirks.CustomCluster, Groups): |
| 298 | + cluster_id = 0x0006 |
| 299 | + |
| 300 | + class XBeeGroupResponse(zigpy.quirks.CustomCluster, Groups): |
| 301 | + import zigpy.zcl.foundation as f |
| 302 | + |
| 303 | + cluster_id = 0x8006 |
| 304 | + ep_attribute = 'xbee_groups_response' |
| 305 | + |
| 306 | + client_commands = {**Groups.client_commands} |
| 307 | + client_commands[0x0004] = ('remove_all_response', (f.Status, ), True) |
| 308 | + |
| 309 | + def __init__(self, *args, **kwargs): |
| 310 | + super().__init__(*args, **kwargs) |
| 311 | + self.node_desc = NodeDescriptor(0x01, 0x40, 0x8e, 0x101e, 0x52, |
| 312 | + 0x00ff, 0x2c00, 0x00ff, 0x00) |
| 313 | + |
| 314 | + replacement = { |
| 315 | + 'endpoints': { |
| 316 | + XBEE_ENDPOINT_ID: { |
| 317 | + 'device_type': 0x0050, |
| 318 | + 'manufacturer': 'Digi', |
| 319 | + 'model': 'XBee', |
| 320 | + 'profile_id': 0xc105, |
| 321 | + 'input_clusters': [XBeeGroup, XBeeGroupResponse], |
| 322 | + 'output_clusters': [], |
| 323 | + } |
| 324 | + } |
| 325 | + } |
0 commit comments