Skip to content

Commit

Permalink
Rename add_neighbour to update_neighbor and document action fie…
Browse files Browse the repository at this point in the history
…ld (#238)

* Rename `add_neighbour` to `update_neighbor` and document `action` field

* Fix unit tests
  • Loading branch information
puddly authored Dec 13, 2023
1 parent 09cd1b3 commit cc1f018
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ async def test_add_neighbour(api, mock_command_rsp):

assert api._command.mock_calls == [
call(
deconz_api.CommandId.add_neighbour,
unknown=0x01,
deconz_api.CommandId.update_neighbor,
action=deconz_api.UpdateNeighborAction.ADD,
nwk=0x1234,
ieee=t.EUI64.convert("aa:bb:cc:dd:11:22:33:44"),
mac_capability_flags=0x12,
Expand Down
16 changes: 10 additions & 6 deletions zigpy_deconz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CommandId(t.enum8):
aps_data_indication = 0x17
zigbee_green_power = 0x19
mac_poll = 0x1C
add_neighbour = 0x1D
update_neighbor = 0x1D
mac_beacon_indication = 0x1F


Expand Down Expand Up @@ -168,6 +168,10 @@ class IndexedEndpoint(Struct):
descriptor: SimpleDescriptor


class UpdateNeighborAction(t.enum8):
ADD = 0x01


NETWORK_PARAMETER_TYPES = {
NetworkParameter.mac_address: (None, t.EUI64),
NetworkParameter.nwk_panid: (None, t.PanId),
Expand Down Expand Up @@ -199,12 +203,12 @@ class Command(Struct):


COMMAND_SCHEMAS = {
CommandId.add_neighbour: (
CommandId.update_neighbor: (
{
"status": Status.SUCCESS,
"frame_length": FRAME_LENGTH,
"payload_length": PAYLOAD_LENGTH,
"unknown": t.uint8_t,
"action": UpdateNeighborAction,
"nwk": t.NWK,
"ieee": t.EUI64,
"mac_capability_flags": t.uint8_t,
Expand All @@ -213,7 +217,7 @@ class Command(Struct):
"status": Status,
"frame_length": t.uint16_t,
"payload_length": t.uint16_t,
"unknown": t.uint8_t,
"action": UpdateNeighborAction,
"nwk": t.NWK,
"ieee": t.EUI64,
"mac_capability_flags": t.uint8_t,
Expand Down Expand Up @@ -837,8 +841,8 @@ async def add_neighbour(
self, nwk: t.NWK, ieee: t.EUI64, mac_capability_flags: t.uint8_t
) -> None:
await self._command(
CommandId.add_neighbour,
unknown=0x01,
CommandId.update_neighbor,
action=UpdateNeighborAction.ADD,
nwk=nwk,
ieee=ieee,
mac_capability_flags=mac_capability_flags,
Expand Down

0 comments on commit cc1f018

Please sign in to comment.