From cc1f018ee91bba0c5dd483a2c20cf9b48d56aa93 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:54:53 -0500 Subject: [PATCH] Rename `add_neighbour` to `update_neighbor` and document `action` field (#238) * Rename `add_neighbour` to `update_neighbor` and document `action` field * Fix unit tests --- tests/test_api.py | 4 ++-- zigpy_deconz/api.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index fe8e5a0..2edfe10 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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, diff --git a/zigpy_deconz/api.py b/zigpy_deconz/api.py index d1d54e8..226bfe1 100644 --- a/zigpy_deconz/api.py +++ b/zigpy_deconz/api.py @@ -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 @@ -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), @@ -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, @@ -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, @@ -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,