Skip to content

Conversation

@Nerivec
Copy link
Collaborator

@Nerivec Nerivec commented Aug 10, 2025

Requires Koenkk/zigbee-herdsman#1479

TODO:

  • support for custom clusters (only custom cluster types required for current code have been added)
  • heavy changes in toZigbee.light_color, in-depth review needed

and a few more in the code itself

TODO (separate PRs):

  • lib/ewelink -> lots of unnecessary clusterName, writeCommand strings?
  • type validateValue? (could remove quite a few as "x" | "y" like as "toggle" | "off" | "on"
  • globalStore.getValue is typed as any, should refactor

Discovered issues

  • fix: toZigbee.danfoss_heat_supply_request wrong attribute name
  • fix: Danfoss Icon2 wrong attribute name
  • fix: bacchus using wrong payload format in timeHHMM
  • fix: ambiguous attr ID hex format in shinasystem fzLocal.ct_direction & tzLocal.ct_direction
  • fix: ambiguous attr value format in legrand tzLegrand.calibration_mode
  • fix: invalid payload formats in namron toZigbee.namron_edge_thermostat_vacation_date
  • fix: invalid payload formats in namron toZigbee.namron_edge_thermostat_holiday_temp

from commands typing:

  • fix: cover_via_brightness using invalid value type in command
  • fix: fan_speed using invalid value type in command
  • fix: twinguardSmokeDetector initiateTestMode command missing payload (was using manuf opts in place, i.e. manuf opts were ignored)
  • fix: twinguardSetup pairingCompleted command missing payload (was using manuf opts in place, i.e. manuf opts were ignored)
  • fix: manuSpecificYokisDevice openNetwork using improper casing in command name
  • fix: manuSpecificYokisInput sendPress using improper custom cluster name
  • fix: manuSpecificYokisInput sendRelease using improper custom cluster name
  • fix: manuSpecificYokisInput selectInputMode using improper custom cluster name

@Nerivec
Copy link
Collaborator Author

Nerivec commented Aug 10, 2025

@Koenkk can you take a look at the few remaining errors? Some legacy stuff, and a few weird occurrences.

Errors  Files
     3  src/devices/danfoss.ts:896
     2  src/devices/xyzroe.ts:83
     1  src/lib/develco.ts:55
    14  src/lib/legacy.ts:5500

@Nerivec Nerivec force-pushed the zh-zcl-typing branch 3 times, most recently from 57089b3 to 24baaa2 Compare August 12, 2025 19:04
}
await entityToUse.read(cluster, [keyToUse], {
// XXX: far too dynamic to properly type
await entityToUse.read(cluster, [keyToUse] as Parameters<typeof entityToUse.read>[1], {
Copy link
Collaborator Author

@Nerivec Nerivec Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohankapoorcom in case you have some time to look this over, don't need to include changes in this PR, but would be nice if we could type this better in the future. Seems a lot of Inovelli code is very dynamic, which is good for size, but very hard to properly type (i.e. more dangerous).
The base would be to have statically-defined cluster name and attribute name (not dynamically generated with string manipulation & co) whenever there are calls to ZH, which would allow to use the new typing introduced in ZH and used elsewhere in this PR.
Note: a little manipulation is doable (example) but more advanced stuff like split, etc. breaks down typing to plain string which we can't validate against cluster types.

@Nerivec Nerivec requested a review from Copilot August 13, 2025 02:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adjusts to new typing from zigbee-herdsman (ZH) and fixes multiple discovered issues across the codebase. The primary purpose is to adapt the codebase to stricter type safety from ZH updates while fixing various bugs found during this process.

Key changes:

  • Update type imports and interface definitions to match new ZH typing system
  • Fix multiple attribute names, payload formats, and command structures
  • Enhance type safety with custom cluster definitions and proper type annotations

Reviewed Changes

Copilot reviewed 70 out of 71 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/tuya.test.ts Reorder import statement for type consistency
src/lib/utils.ts Add type imports and enhance function signatures with generics for better type safety
src/lib/ubisys.ts Add custom cluster interfaces and improve type annotations throughout
src/lib/types.ts Update Tuya DpValue data field type from union to Buffer
src/lib/tuya.ts Fix data type conversions to use Buffer consistently and improve type safety
src/lib/sunricher.ts Add custom cluster interfaces and fix type annotations
src/lib/reporting.ts Add type imports and enhance payload function with generics
src/lib/philips.ts Add custom cluster interface and improve type safety
src/lib/nodon.ts Add custom cluster interface and enhance type annotations
src/lib/namron.ts Fix payload format issues and improve type annotations
src/lib/modernExtend.ts Major updates to add generic type parameters throughout and improve type safety
src/lib/lumi.ts Update function signatures with proper generic types
src/lib/light.ts Add type imports and improve function parameter types
src/lib/legrand.ts Fix attribute value format issues and improve type safety
src/lib/legacy.ts Fix command structure and remove unnecessary type conversions
src/lib/ikea.ts Add custom cluster interfaces and improve type annotations
src/lib/generateDefinition.ts Remove unnecessary generic type parameters
src/lib/ewelink.ts Add type imports and fix command structures
src/lib/develco.ts Add custom cluster interfaces and improve type annotations
src/devices/yokis.ts Add comprehensive custom cluster interfaces and fix command structures
src/devices/yandex.ts Add custom cluster interfaces and improve type safety
src/devices/xyzroe.ts Fix attribute name and improve type annotations
src/devices/wirenboard.ts Add custom cluster interface and improve type safety
src/devices/ubisys.ts Add type imports and enhance read/write operations with proper typing
src/devices/tuya.ts Add custom cluster interface and fix command structures
src/devices/tubeszb.ts Fix attribute type annotation
src/devices/sunricher.ts Add custom cluster interfaces and improve type annotations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@Nerivec Nerivec marked this pull request as ready for review August 15, 2025 14:52
@Koenkk Koenkk changed the base branch from master to integration August 16, 2025 12:22
@Nerivec
Copy link
Collaborator Author

Nerivec commented Aug 16, 2025

I reverted the tsconfig module change to NodeNext. It would require testing with external converters to see if it impacts importing & whatnot (it at least requires using .js extensions in the repos for dyn imports). Shouldn't include it in this big PR anyway.

@Nerivec Nerivec merged commit 68baad3 into Koenkk:integration Aug 16, 2025
2 of 3 checks passed
@Nerivec Nerivec deleted the zh-zcl-typing branch August 16, 2025 16:08
Koenkk added a commit that referenced this pull request Aug 17, 2025
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Koen Kanters <[email protected]>
Koenkk added a commit to HermesHonshappo/zigbee-herdsman-converters that referenced this pull request Aug 18, 2025
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Koen Kanters <[email protected]>
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.

2 participants