From 39895f4571bffc4f55bea2239b80bad8a6f707af Mon Sep 17 00:00:00 2001 From: zigpy-review-bot <286747149+zigpy-review-bot@users.noreply.github.com> Date: Sun, 15 Nov 2026 04:04:36 +0100 Subject: [PATCH] Fix tests for zigpy's Green Power endpoint and commissioning broadcast zigpy 2.4 registers the Green Power endpoint (242) on the coordinator and sends a Green Power broadcast on startup and when permitting joins. The test Z-Stack server had no handler for that broadcast, which failed ~137 application tests with `CommandNotRecognized`. --- tests/application/test_joining.py | 2 +- tests/application/test_startup.py | 5 +++-- tests/conftest.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/application/test_joining.py b/tests/application/test_joining.py index 886a92d..ed2c092 100644 --- a/tests/application/test_joining.py +++ b/tests/application/test_joining.py @@ -39,7 +39,7 @@ async def test_permit_join(device, mocker, make_application): request=zdo_request_matcher( dst_addr=t.AddrModeAddress(t.AddrMode.Broadcast, 0xFFFC), command_id=zdo_t.ZDOCmd.Mgmt_Permit_Joining_req, - TSN=2, + TSN=4, # zigpy sends a Green Power commissioning broadcast first (TSN 3) zdo_PermitDuration=10, zdo_TC_Significant=0, ), diff --git a/tests/application/test_startup.py b/tests/application/test_startup.py index 8211bc9..20142d5 100644 --- a/tests/application/test_startup.py +++ b/tests/application/test_startup.py @@ -103,10 +103,11 @@ async def test_endpoints(device, make_application): await app.startup(auto_form=False) - # We currently just register two endpoints - assert len(endpoints) == 2 + # We register the two application endpoints and zigpy's Green Power endpoint + assert len(endpoints) == 3 assert 1 in app._device.endpoints assert 2 in app._device.endpoints + assert 242 in app._device.endpoints await app.shutdown() diff --git a/tests/conftest.py b/tests/conftest.py index 58b2690..8c1b8bf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -594,6 +594,16 @@ def permit_join(self, request): c.ZDO.MgmtPermitJoinRsp.Callback(Src=0x0000, Status=t.ZDOStatus.SUCCESS), ] + @reply_to( + c.AF.DataRequestExt.Req( + partial=True, DstEndpoint=242, SrcEndpoint=242, ClusterId=0x0021 + ) + ) + def on_green_power_broadcast(self, req): + # Newer zigpy sends a Green Power broadcast (e.g. a commissioning window + # request) to the GP endpoint. Just acknowledge it. + return c.AF.DataRequestExt.Rsp(Status=t.Status.SUCCESS) + @reply_to(c.AF.DataRequestExt.Req(partial=True, DstEndpoint=0)) def on_zdo_request(self, req): kwargs = deserialize_zdo_command(req.ClusterId, req.Data[1:])