Changing the data type by name helpers to use data type name and cluster#1669
Conversation
brdandu
commented
Nov 10, 2025
- Updating types.getSignAndSizeOfZclType to types.getSignAndSizeOfZclTypeAndClusterId for better accuracy and avoiding duplicate data types across clusters.
- updating the code associated with the above as required in the code.
- deprecating as_bytes and data_types_for_enum as they are no longer used.
- Github: ZAP selectEnumByName and selectBitmapByName need to switch to selectEnumByNameAndClusterName and selectBitmapByNameAndClusterName #1592
Summary of ChangesHello @brdandu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the accuracy of ZCL data type resolution within the system by introducing cluster-awareness. The primary goal is to prevent ambiguities and errors that arise when data types with identical names exist in different ZCL clusters. This is achieved by implementing a new function that prioritizes cluster-specific type definitions, leading to more robust and precise data handling throughout the application. Additionally, older, less accurate helpers have been deprecated, and documentation has been updated to reflect these changes. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a necessary change to handle cluster-specific data types by adding a clusterId to the type resolution logic. The new function getSignAndSizeOfZclTypeAndClusterId and its integration into various helpers are well-implemented. The documentation has also been updated accordingly.
My review includes a few suggestions to improve maintainability by reducing code duplication in helper-zcl.js and types.js. I also found a minor bug in helper-c.js where a helper is exported twice, and a typo in a log message in types.js. Overall, this is a good improvement.
cb3f402 to
6cb445e
Compare
tecimovic
left a comment
There was a problem hiding this comment.
Generally looks good, but I have no way of being able to go into details of this...
193d651 to
807c101
Compare
- Updating types.getSignAndSizeOfZclType to types.getSignAndSizeOfZclTypeAndClusterId for better accuracy and avoiding duplicate data types across clusters. - updating the code associated with the above as required in the code. - deprecating as_bytes and data_types_for_enum as they are no longer used. - Handling clusterId for all the helpers. Now the helpers can mention clusterId=ID-NUMBER along with the helpers in .zapt templates to account for the helpers. The helpers in helpers.js files now extract this from the this object automatically - Updating the feature level of zap - Adding unit tests for the as_underlying_zcl_type helper with cluster Id reference - Github: ZAP project-chip#1592
807c101 to
2708354
Compare
| - language: determines the output of the helper based on language | ||
| for eg: (as_type_min_value language='c++') will give the output specific to | ||
| the c++ language. | ||
| - clusterId: The ID of the cluster the type belongs to |
There was a problem hiding this comment.
Is this the "id" in the sense of database ID, or the "id" in the sense of the actual spec-defined cluster identifier? It's not obvious just looking at this documentation.
| - language: determines the output of the helper based on language | ||
| for eg: (as_type_max_value language='c++') will give the output specific to | ||
| the c++ language. | ||
| - clusterId: The ID of the cluster the type belongs to |
| | Param | Type | Description | | ||
| | --- | --- | --- | | ||
| | type | <code>\*</code> | | | ||
| | options | <code>\*</code> | Available Options: - clusterId: The ID of the cluster the type belongs to | |
| * [~nullStringDefaultValue(type)](#module_JS API_ type related utilities..nullStringDefaultValue) ⇒ <code>string</code> | ||
| * [~processZclTypeSignAndSize(db, dataType, type, packageIds, options, clusterId, clusterName)](#module_JS API_ type related utilities..processZclTypeSignAndSize) ⇒ | ||
| * [~getSignAndSizeOfZclType(type, context, options)](#module_JS API_ type related utilities..getSignAndSizeOfZclType) ⇒ | ||
| * [~getSignAndSizeOfZclTypeAndClusterId(db, type, clusterId, packageIds, options)](#module_JS API_ type related utilities..getSignAndSizeOfZclTypeAndClusterId) ⇒ <code>size:'bits'</code> |
There was a problem hiding this comment.
See above about id.
| | type | <code>\*</code> | | The type name (for error logging) | | ||
| | packageIds | <code>\*</code> | | Package IDs | | ||
| | options | <code>\*</code> | | Processing options | | ||
| | clusterId | <code>\*</code> | <code></code> | Optional cluster ID for cluster-specific queries | |
| | --- | --- | | ||
| | db | <code>\*</code> | | ||
| | type | <code>\*</code> | | ||
| | clusterId | <code>\*</code> | |
| | --- | --- | | ||
| | db | <code>\*</code> | | ||
| | enum_name | <code>\*</code> | | ||
| | clusterId | <code>\*</code> | |
There was a problem hiding this comment.
I'll stop commenting on this, but it's a general problem in all these APIs.
| } | ||
|
|
||
| /** | ||
| * Given a zcl device type returns its sign, size and zcl data type info stored |
There was a problem hiding this comment.
This has nothing to do with "device type"....
| } | ||
|
|
||
| /** | ||
| * Given a zcl device type and cluster name returns its sign, size and zcl data type info stored |
There was a problem hiding this comment.
Again, not "device type".