Feature/typed cluster interfaces#157
Draft
RobinBol wants to merge 3 commits intofeature/zigbee-basic-extendedfrom
Draft
Feature/typed cluster interfaces#157RobinBol wants to merge 3 commits intofeature/zigbee-basic-extendedfrom
RobinBol wants to merge 3 commits intofeature/zigbee-basic-extendedfrom
Conversation
- Add scripts/generate-types.js to parse cluster definitions and generate
TypeScript interfaces with proper attribute/command typing
- Generate typed attributes for each cluster with:
- Proper enum8/enum16 types as string literal unions
- Proper map8/map16 types as Partial<Record<flag, boolean>>
- Correct primitive type mappings (uint8→number, bool→boolean, etc.)
- Generate typed command methods with proper argument types
- Add ClusterRegistry interface for type-safe cluster access
- Add npm run generate-types script for regenerating types
- Add typescript as devDependency for type verification
Usage:
const cluster = endpoint.clusters.doorLock;
if (cluster) {
const attrs = await cluster.readAttributes(['lockState', 'lockType']);
// attrs.lockState is typed as 'notFullyLocked' | 'locked' | 'unlocked' | ...
}
Automatically regenerates index.d.ts when cluster definitions change: - Triggers on push to develop when lib/clusters/*.js files change - Runs generate-types script and commits updated types - Uses [skip ci] to prevent infinite loop
There was a problem hiding this comment.
Pull request overview
This PR introduces automated TypeScript type generation for zigbee-clusters by adding a script that parses JavaScript cluster definitions and generates corresponding TypeScript interfaces.
Changes:
- Added a type generation script that parses cluster files and generates TypeScript interfaces
- Added npm script and GitHub Actions workflow to automate type generation
- Added TypeScript and @types/node as dev dependencies
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/generate-types.js | New script that parses cluster definitions and generates TypeScript interfaces with typed attributes and commands |
| package.json | Added generate-types npm script and TypeScript-related dev dependencies |
| .github/workflows/generate-types.yml | GitHub Actions workflow to automatically regenerate types when cluster files change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review feedback by documenting that Buffer arguments (octstr, securityKey128, buffer types) are intentionally optional because ZCL allows empty octet strings and the runtime serializes undefined values as empty Buffers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
TODO: