Repository navigation
Fit the Green Power endpoint into two-slot firmware - #281
Conversation
zigpy 2.4.0 registers the Green Power endpoint 242 next to the HA (1) and ZLL (2) endpoints, but ConBee II and RaspBee II firmware only has two endpoint slots. When both slots already held zigpy's endpoints 1 and 2, `add_endpoint` raised `No available endpoint slots exist` and startup failed on every attempt. Otherwise, a written slot was never marked as used, so endpoint 242 overwrote endpoint 2 and slot 1 was rewritten twice on every start. Register all endpoints at once instead: when they don't fit, drop the ZLL endpoint (nothing is sent from it), the same layout deCONZ and Z2M use, keep endpoints that are already configured and only write the rest.
A configured endpoint with the ID of one of zigpy's replaces it, as a standalone `add_endpoint` call already did, instead of taking a slot of its own. Only zigpy's ZLL endpoint 2 makes room on two-slot firmware, a configured ZLL endpoint is kept.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #281 +/- ##
==========================================
+ Coverage 99.15% 99.17% +0.02%
==========================================
Files 7 7
Lines 945 971 +26
==========================================
+ Hits 937 963 +26
Misses 8 8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer acceptance of the loss of incoming ZLL reception and hardware validation of two-slot startup and Green Power proxy reception are still needed, as slot-table mocks cannot verify firmware behavior.
No open issues 🎉
What changed in this PR
Fixes endpoint registration for ConBee II / RaspBee II firmware with only two slots, addressing the ZHA startup failure introduced by zigpy’s Green Power endpoint registration.
Changes:
- Collects endpoints before assigning slots, omitting ZLL endpoint 2 when needed to fit HA and Green Power.
- Preserves matching descriptors, supports same-ID overrides, and tracks registered endpoints to prevent unintended overwrites.
- Adds regression tests for slot layouts, repeat registration, capacity errors, overrides, and later endpoint additions.
| File | Description |
|---|---|
zigpy_deconz/zigbee/application.py |
Batches endpoint registration and allocates available firmware slots while avoiding unnecessary writes. |
tests/test_application.py |
Tests slot allocation, registration stability, capacity handling, and endpoint replacement. |
Review effort: Balanced
|
(note: do not press "Delete branch" yet, as the custom component installs this branch currently) |
Summary
Fixes ZHA failing to start on ConBee II / RaspBee II with zigpy 2.4.x:
No available endpoint slots exist(home-assistant/core#189366).Closes #280
zigpy 2.4.0 registers the Green Power endpoint 242 next to the HA endpoint 1 and the ZLL endpoint 2, but the ConBee II / RaspBee II firmware only has two endpoint slots.
add_endpointhandled one endpoint at a time:ValueError, so startup failed on every attempt.Changes
register_endpointsnow collects all of zigpy's endpoints first, then fits them into the slots in one pass.add_endpointcall already could.send_packetsends everything except ZDO (endpoint 0) and Green Power (242) from endpoint 1. If it still doesn't fit (extra endpoints configured on a two-slot stick), it raises as before.add_endpointcall goes through the same path with the endpoints registered so far, so it can't overwrite one of them.Firmware with more slots (a four-slot ConBee II test build exists) keeps endpoint 2 and puts 242 in a slot not holding one of zigpy's endpoints.
Trade-off on two-slot firmware
puddly's hardware test on a ConBee II (0x26780700) shows that the firmware only delivers incoming frames whose destination endpoint is in a slot with a matching profile, and doesn't ACK the others. With two slots, one of zigpy's three endpoints is always missing:
This PR gives up the ZLL endpoint, the same choice deCONZ and Z2M make. Sending is unaffected either way, since the firmware doesn't check source endpoints.
Testing
register_endpointsagainst mocked slot tables: two slots upgraded from zigpy ≤ 2.3 (ValueErrorbefore), two slots already holding 1 + 242 (two writes per start before, none now), two slots from another application, and three/four slots. Each also checks that registering again writes nothing.add_endpointuses a free slot or the slot with the same endpoint ID.dev.