Secondary mcu with dimmer support - #484
Open
charliesjc wants to merge 30 commits into
Open
Conversation
Add missing clusterRegisterFunc so the 0xFC10 dimmer config cluster is advertised, fixing Z2M "no input cluster manuSpecificTuyaDimmerConfig".
Register manufacturer-specific clusters (0xFC00-0xFFFF) with the Tuya manufacturer code (0x125D) instead of 0, so Z2M can recognize them as manufacturer-specific and match them to the converter's custom cluster definitions.
HA turns dimmers on by sending MoveToLevelWithOnOff (0x04), which carries only a brightness value - it never sends a plain OnOff ON. Per ZCL, that command also changes the OnOff state, so the dimmer cluster now writes the on/off DP (bool 1 when level > 0, 0 when level == 0) alongside the level DP. This makes the relay actually switch on/off instead of only dimming.
Only initialise the MCU UART when the device has dimmers (secondary MCU), so PB1/PB7 aren't reassigned as UART pins on the ~199 Telink boards that use them as GPIOs.
… on hardware side only
The Tuya MCU protocol expects the frame sequence number to advance by +1 per frame, wrapping from 0xFFF0 back to 0x0000. The previous code advanced by +0x10, producing gaps in the sequence the MCU ignored.
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.
Full UART comms to use a secondary MCU and a new cluster for dimmer support was added. While I've focused on dimmers for my needs, there are only small changes required to make this useful for any device that uses a secondary MCU. I.e. I've assumed pins B1 and B7 for UART which might not be valid for all Zigbee boards, but easily fixed.
I've also used device_db.yaml for datapoint parameter assignment of various functions for the secondary MCU.