Conversation
| { | ||
| "extends": "athom" | ||
| } No newline at end of file | ||
| } |
| "homepage": "https://github.com/athombv/node-zigbee-clusters#readme", | ||
| "devDependencies": { | ||
| "@athombv/jsdoc-template": "^1.6.3", | ||
| "@types/homey": "npm:homey-apps-sdk-v3-types@^0.3.12", |
There was a problem hiding this comment.
This package should not be coupled to the SDK types.
| async function stall(): Promise<void> { | ||
| await new Promise(resolve => { | ||
| setTimeout(resolve, 1_000_000_000); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Not sure what this is used for, the only call of this method is commented out
| if (definition.args !== undefined) { | ||
| stringBuilder.print(", args: "); | ||
| if (Object.keys(definition.args).length === 0) { | ||
| stringBuilder.print("Record<never, never> /* TODO fix */ "); |
| } else if (typeName.startsWith('map')) { | ||
| formatMapDataType(stringBuilder, className, command, typeName, typeArgs); | ||
| } else if (typeName.startsWith("_Array")) { | ||
| stringBuilder.print("Array<unknown>"); |
There was a problem hiding this comment.
_Array types just emit Array<unknown>. The old script resolved the inner type. This loses type safety on array attributes/args.
| await fs.appendFile(filePath, templateBody); | ||
|
|
||
| console.log("Done!"); | ||
| // await stall(); |
There was a problem hiding this comment.
| // await stall(); |
| stringBuilder.decreaseIndent(); | ||
| stringBuilder.printLine("};"); | ||
|
|
||
| await fs.appendFile(filePath, stringBuilder.toString()); |
There was a problem hiding this comment.
Why repeatedly append to the file instead of building the full string in memory?
| timeout?: number, | ||
| disableDefaultResponse?: boolean, | ||
| }, | ||
| ): Promise<void>; |
There was a problem hiding this comment.
Quite some methods now lost the response type.
| COMMANDS: unknown; | ||
| class OnOffCluster<Attributes extends types.AttributeDefinitions = OnOffClusterAttributes, Commands extends types.CommandDefinitions = OnOffClusterCommands> extends Cluster<Attributes, Commands> { | ||
| setOff( | ||
| args: { |
There was a problem hiding this comment.
Every generated command method requires args: { manufacturerId?: number } even for no-arg commands like setOff(). Old types had opts? only. Consumers now must pass {} to call simple commands.
| }, | ||
| }, | ||
| getGroupMembership: { id: 0x02, direction: "DIRECTION_SERVER_TO_CLIENT", args: { | ||
| groupIds: ZCLDataType<Array<unknown>>, |
There was a problem hiding this comment.
This should not be unknown but number
| multiplier: { id: 0x301, type: ZCLDataType<number> }, | ||
| divisor: { id: 0x302, type: ZCLDataType<number> }, | ||
| siteId: { id: 0x307, type: ZCLDataType<string> }, | ||
| meterSerialNumber: { id: 0x308, type: ZCLDataType<string> }, |
There was a problem hiding this comment.
octstr mapped to string instead of Buffer. Old script used Buffer. Affects siteId, meterSerialNumber, pinCode, etc.
Depends on athombv/node-data-types#42
Some of the generated types were incomplete, so I rewrote the generation to document more of the properties available at runtime, as well as adding some additional types based on the JS sources and runtime introspection.
I enabled type checking for the definition file and added the SDK types, since these are used by the ZCLNode.
Some broken enum8 attributes in the Metering cluster definition, where the function was not properly called, were also fixed.