Skip to content

Fix gpepIncomingMessageHandler schema for EZSP v13+ - #746

Open
bedge117 wants to merge 1 commit into
zigpy:devfrom
bedge117:fix/ezsp-v13-gpep-schema
Open

Fix gpepIncomingMessageHandler schema for EZSP v13+#746
bedge117 wants to merge 1 commit into
zigpy:devfrom
bedge117:fix/ezsp-v13-gpep-schema

Conversation

@bedge117

@bedge117 bedge117 commented Sep 5, 2026

Copy link
Copy Markdown

Fix gpepIncomingMessageHandler schema for EZSP v13+

Problem

Every incoming Green Power frame on an EmberZNet 7.x NCP fails to parse and is dropped before it reaches the application:

WARNING bellows.ezsp.protocol: Failed to parse frame gpepIncomingMessageHandler: b'7fdbc1009eea43009eea43000002010000c116000010153064adff00'
WARNING bellows.ezsp: Failed to parse frame, ignoring

This is the long-standing symptom behind the Friends-of-Hue / PTM 215Z reports (e.g. zigpy/zha-device-handlers#2477) and blocks any Green Power work on top of bellows.

Cause

gpepIncomingMessageHandler is only defined in the v4 schema (and redefined in v17). Everything from v5 through v16 inherits the v4 layout, which predates the EmberZNet 7.x wire format. In 7.x the EmberGpAddress member is serialized as applicationId, an 8-byte GPD id union, then endpoint; the v4 schema expects a different, longer layout and runs out of bytes.

Fix

Redefine the handler for EZSP v13 (inherited by v14 and v16) with the 7.x layout:

status, gpdLink, sequenceNumber, applicationId, gpdIdUnion[8], endpoint, gpdfSecurityLevel, gpdfSecurityKeyType, autoCommissioning, bidirectionalInfo, gpdSecurityFrameCounter, gpdCommandId, mic, proxyTableIndex, gpdCommandPayload

This matches the field order the zigbee-herdsman ember adapter uses for the same callback.

Verification

Captured live from a Home Assistant SkyConnect running EmberZNet 7.5.1 (EZSP v13) receiving an EnOcean PTM 215Z (Philips Hue Tap). With this change the frames parse correctly: source ID 0x0043EA9E, security level 2 (full frame counter + MIC), a frame counter that increments per press, and distinct GPD command IDs per button (0x100x12, 0x22). One captured operational frame is added to tests/test_ezsp_v13.py as a regression test. Full test suite passes.

Notes

  • The v17 redefinition uses the EmberGpAddress struct type, whose Python field order (gpdIeeeAddress, sourceId, applicationId, endpoint) does not match this wire layout either, so it likely needs the same treatment. Left out of this PR to keep the change minimal and limited to what was verified on hardware.
  • Only the parse is fixed here. Routing the parsed frame to the application (packet_received as a GP Notification on endpoint 242 / cluster 0x0021) is a separate change that depends on zigpy's in-progress Green Power runtime (zgp: add the Green Power manager, device, and proxy runtime zigpy#1848).

The inherited schema predates the EmberZNet 7.x wire format, so every
incoming Green Power frame failed to parse and was dropped before
reaching the application. Redefine the handler for EZSP v13 with the
layout 7.x NCPs emit: applicationId, 8-byte GPD id union, and endpoint,
followed by the security, frame counter, command, MIC, proxy table
index, and payload fields.

Verified against frames captured from an EmberZNet 7.5.1 NCP receiving
an EnOcean PTM 215Z switch; one such frame is added as a regression
test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant