Skip to content

Commit e1e2b1e

Browse files
committed
Keep track of children inside of internal, for now
1 parent 28d65c8 commit e1e2b1e

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

tests/tools/test_network_backup_restore.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def backup_json():
5454
"internal": {
5555
"creation_time": "2021-02-16T22:29:28+00:00",
5656
"zstack": {"version": 3.3},
57+
"children": ["000b57fffe38b212"],
5758
},
5859
"source": "[email protected]",
5960
"version": 1,

zigpy_znp/tools/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
"zstack": {
3636
"type": "object",
3737
"properties": {
38-
"tclk_seed": {"type": "string", "pattern": "[a-fA-F0-9]{32}"}
38+
"tclk_seed": {"type": "string", "pattern": "[a-fA-F0-9]{32}"},
39+
"children": {
40+
"type": "array",
41+
"items": {"type": "string", "pattern": "[a-fA-F0-9]{16}"},
42+
},
3943
},
4044
}
4145
},
@@ -70,7 +74,6 @@
7074
"properties": {
7175
"nwk_address": {"type": "string", "pattern": "[a-fA-F0-9]{4}"},
7276
"ieee_address": {"type": "string", "pattern": "[a-fA-F0-9]{16}"},
73-
"is_child": {"type": "boolean"},
7477
"link_key": {
7578
"type": "object",
7679
"properties": {

zigpy_znp/tools/network_backup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ async def backup_network(znp: ZNP) -> t.JSONType:
5353
"zstack": {
5454
"version": znp.version,
5555
},
56+
"children": [
57+
neighbor.ieee.serialize()[::-1].hex()
58+
for neighbor in znp.network_info.neighbor_table
59+
],
5660
},
5761
},
5862
"coordinator_ieee": znp.node_info.ieee.serialize()[::-1].hex(),
@@ -71,11 +75,9 @@ async def backup_network(znp: ZNP) -> t.JSONType:
7175
}
7276

7377
if znp.network_info.stack_specific.get("zstack", {}).get("tclk_seed"):
74-
obj["stack_specific"] = {
75-
"zstack": {
76-
"tclk_seed": znp.network_info.stack_specific["zstack"]["tclk_seed"]
77-
}
78-
}
78+
obj.setdefault("stack_specific", {}).setdefault("zstack", {})[
79+
"tclk_seed"
80+
] = znp.network_info.stack_specific["zstack"]["tclk_seed"]
7981

8082
# Ensure our generated backup is valid
8183
validate_backup_json(obj)

zigpy_znp/tools/network_restore.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ def json_backup_to_zigpy_state(
5151
network_info.key_table = []
5252
network_info.neighbor_table = []
5353

54+
children = backup["stack_specific"].get("zstack", {}).get("children")
55+
5456
for obj in backup["devices"]:
5557
node = zigpy.state.NodeInfo()
5658
node.nwk, _ = t.NWK.deserialize(bytes.fromhex(obj["nwk_address"])[::-1])
5759
node.ieee, _ = t.EUI64.deserialize(bytes.fromhex(obj["ieee_address"])[::-1])
5860
node.logical_type = None
5961

60-
network_info.neighbor_table.append(node)
62+
if children is None or obj["ieee_address"] in children:
63+
network_info.neighbor_table.append(node)
6164

6265
if "link_key" in obj:
6366
key = zigpy.state.Key()

0 commit comments

Comments
 (0)