feat: enhance ZCL error handling and add OTA cluster attributes and commands#172
Merged
feat: enhance ZCL error handling and add OTA cluster attributes and commands#172
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the Zigbee OTA Upgrade cluster implementation and improves ZCL command/response handling by enabling status-aware errors and ensuring cluster-specific responses are framed correctly. It also updates type generation to better represent ZCL status enums and optional-field encoding behavior.
Changes:
- Add
ZCLErrorto propagate ZCL status codes into Default Response frames, plus tests for status propagation/encoding. - Implement the OTA cluster with spec-defined attributes/commands and support
encodeMissingFieldsBehavior: 'skip'for variant/optional fields. - Update response framing and type-generation to account for cluster-specific responses and status enum typing.
Reviewed changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
lib/util/index.js |
Introduces ZCLError for status-aware errors. |
lib/Endpoint.js |
Encodes ZCL status into Default Response; fixes clusterSpecific bit on responses. |
lib/Cluster.js |
Forwards encodeMissingFieldsBehavior into ZCLStruct construction. |
lib/BoundCluster.js |
Passes response metadata through to endpoint framing. |
lib/clusters/ota.js |
Implements OTA attributes and commands (including variant responses). |
scripts/generate-types.js |
Enhances TS generation (status enum aliasing, optionality rules, new exports). |
index.d.ts |
Regenerated typings including OTA + ZCLError/bind() signatures. |
index.js |
Exports ZCLError. |
test/testZCLError.js |
Adds tests covering Default Response status propagation/encoding. |
test/ota.js |
Adds tests for optional/variant field encoding behavior in OTA commands. |
package.json / package-lock.json |
Bumps @athombv/data-types to support missing-field encoding behavior. |
AGENTS.md |
Documents conventions for optional fields and server→client command exposure. |
.gitignore |
Ignores .envrc. |
Comments suppressed due to low confidence (1)
scripts/generate-types.js:306
ZCLNodeEndpoint.bind()now referencesBoundCluster, butBoundClusteris only declared inside the laterdeclare module "zigbee-clusters" { ... }block. In TypeScript, names declared inside a module-augmentation block are not automatically in scope for the top-level declarations in the file, so this can make the generatedindex.d.tsfail to type-check (Cannot find name 'BoundCluster'). Fix by declaring/exportingBoundCluster(andZCLErrorif needed) in the top-level module scope before it’s referenced, or by restructuring the .d.ts to avoid mixing top-level exports with a separatedeclare moduleblock.
attributes: Array<string | number>,
opts?: { timeout?: number }
): Promise<{ [x: string]: unknown }>;
writeAttributes(attributes?: object, opts?: { timeout?: number }): Promise<unknown>;
configureReporting(attributes?: object, opts?: { timeout?: number }): Promise<void>;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
RobinBol
approved these changes
Mar 6, 2026
RobinBol
reviewed
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
'skip'