Skip to content

Commit cc1f018

Browse files
authored
Rename add_neighbour to update_neighbor and document action field (#238)
* Rename `add_neighbour` to `update_neighbor` and document `action` field * Fix unit tests
1 parent 09cd1b3 commit cc1f018

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ async def test_add_neighbour(api, mock_command_rsp):
942942

943943
assert api._command.mock_calls == [
944944
call(
945-
deconz_api.CommandId.add_neighbour,
946-
unknown=0x01,
945+
deconz_api.CommandId.update_neighbor,
946+
action=deconz_api.UpdateNeighborAction.ADD,
947947
nwk=0x1234,
948948
ieee=t.EUI64.convert("aa:bb:cc:dd:11:22:33:44"),
949949
mac_capability_flags=0x12,

zigpy_deconz/api.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class CommandId(t.enum8):
114114
aps_data_indication = 0x17
115115
zigbee_green_power = 0x19
116116
mac_poll = 0x1C
117-
add_neighbour = 0x1D
117+
update_neighbor = 0x1D
118118
mac_beacon_indication = 0x1F
119119

120120

@@ -168,6 +168,10 @@ class IndexedEndpoint(Struct):
168168
descriptor: SimpleDescriptor
169169

170170

171+
class UpdateNeighborAction(t.enum8):
172+
ADD = 0x01
173+
174+
171175
NETWORK_PARAMETER_TYPES = {
172176
NetworkParameter.mac_address: (None, t.EUI64),
173177
NetworkParameter.nwk_panid: (None, t.PanId),
@@ -199,12 +203,12 @@ class Command(Struct):
199203

200204

201205
COMMAND_SCHEMAS = {
202-
CommandId.add_neighbour: (
206+
CommandId.update_neighbor: (
203207
{
204208
"status": Status.SUCCESS,
205209
"frame_length": FRAME_LENGTH,
206210
"payload_length": PAYLOAD_LENGTH,
207-
"unknown": t.uint8_t,
211+
"action": UpdateNeighborAction,
208212
"nwk": t.NWK,
209213
"ieee": t.EUI64,
210214
"mac_capability_flags": t.uint8_t,
@@ -213,7 +217,7 @@ class Command(Struct):
213217
"status": Status,
214218
"frame_length": t.uint16_t,
215219
"payload_length": t.uint16_t,
216-
"unknown": t.uint8_t,
220+
"action": UpdateNeighborAction,
217221
"nwk": t.NWK,
218222
"ieee": t.EUI64,
219223
"mac_capability_flags": t.uint8_t,
@@ -837,8 +841,8 @@ async def add_neighbour(
837841
self, nwk: t.NWK, ieee: t.EUI64, mac_capability_flags: t.uint8_t
838842
) -> None:
839843
await self._command(
840-
CommandId.add_neighbour,
841-
unknown=0x01,
844+
CommandId.update_neighbor,
845+
action=UpdateNeighborAction.ADD,
842846
nwk=nwk,
843847
ieee=ieee,
844848
mac_capability_flags=mac_capability_flags,

0 commit comments

Comments
 (0)