Repository navigation
Secondary MCU (Tuya MCU over UART), AVATTO ZDMS16-2 dimmer - #558
Open
patapovich wants to merge 1 commit into
Open
patapovich wants to merge 1 commit into
patapovich wants to merge 1 commit into
Conversation
Many TS0601 boards have a second microcontroller that drives the outputs and reads the inputs; the Zigbee module only talks to it over UART with the Tuya MCU protocol. This adds that link and maps Tuya datapoints to standard Zigbee clusters, configured from the config string (tokens in docs/contribute/porting.md): - UART link: one frame in flight, ack timeout and write queue, reports with several DPs, status dumps larger than 64 bytes, resync on damaged frames, UART reinit when writes keep failing. The module starts the conversation after boot (not every MCU asks for the network status). - Relays (RT), touch/scene keys as switch inputs (ST), power-on behaviour (PT), datapoints written at boot (IT), settings datapoints as Basic cluster attributes (dp_attributes in device_db). - Dimmers (DM, P, U, DR) on the Level Control cluster: on, off, move, step, move to level, OnLevel. "On" goes to the MCU before the level, levels are scaled to the MCU's min/max brightness both ways, wall switch type and power-on behaviour from the MCU, OnLevel applied as soon as the wall switch turns the light on. Standard Tuya dimmer DPs by default (1..5, 7..11, power-on 14). - MCU firmware version (0x0B) as a Basic cluster attribute, shown in Z2M as mcu_version. - The module button of a dimmer module resets the device. - Boards: AVATTO ZDMS16-2 (_TZE284_jtbgusdc, _TZE204_jtbgusdc), NovaDigital 6 gang (_TZE204_tdhnhhiy), NovaDigital TPZ-2 / Moes SFL02-Z-2 (_TZE200_hktk6hze). - Stub tests for the link, the dimmer, DP attributes and the config. Based on romasku#484 by charliesjc, with work by Gabrielguadag, flattened and extended. Co-authored-by: charliesjc <charliesjc@gmail.com> Co-authored-by: Gabriel Guadagnin <gabrielguadag@gmail.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.
This continues #484 by @charliesjc, with work from @Gabrielguadag, flattened into one commit on top of current main and extended. Both are co-authors of the commit. #484 has been quiet since September and no longer merges cleanly, so I'm opening this as its successor; if you would rather continue in #484, I'm happy to close this one.
What it does
Many
TS0601boards have a second microcontroller that drives the outputs and reads the inputs; the Zigbee module only talks to it over UART with the Tuya MCU protocol. This adds that link and maps Tuya datapoints to standard Zigbee clusters, configured from the config string (tokens documented indocs/contribute/porting.md):RT), touch/scene keys as switch inputs (ST), power-on behaviour (PT), datapoints written at boot (IT), settings datapoints as Basic cluster attributes (dp_attributesindevice_db.yaml).DM,P,U,DR) on the Level Control cluster: on, off, move, step, move to level, OnLevel.mcu_version._TZE284_jtbgusdc,_TZE204_jtbgusdc), NovaDigital 6 gang (_TZE204_tdhnhhiy), NovaDigital TPZ-2 / Moes SFL02-Z-2 (_TZE200_hktk6hze).Changes compared to #484
jtbgusdc;TS0601-ZDMS16-2;DM2;M;.PandUstill override.TS0601-ZDMS16-2instead of plainTS0601, which made the generated converter claim everyTS0601without a fingerprint definition.stock_converter_manufacturer/stock_converter_modelareAVATTO/ZDMS16-2, the stock Z2M definition of this board;TS0601_switchnever got the OTA extension, so the update from stock was not offered._TZE204_jtbgusdcis the same board and has its own entry.dp_attributes, and the changelog entry moved under Upcoming.Related PRs
hal_millis()monotonic, and no steering on a device that is already on a network. The link's timeouts are differences and survive the 268 s jump, but they are only exact with Fix hal_millis() wrap on Telink, config string overflow, steering of joined devices, first input read #555. With Fix hal_millis() wrap on Telink, config string overflow, steering of joined devices, first input read #555, a module button held while the device boots no longer starts steering on a joined device.Tested
_TZE284_jtbgusdc, two_TZE204_jtbgusdc) updated from stock with Z2M OTA, in daily use since 2026-11-16: wall switch, control from Z2M and Home Assistant, OnLevel, power-on behaviour, min/max brightness. After the update from stock, the device needs a reconfigure in Z2M so the reporting binds are made.mcu_versionshowed 1.0.7, and on, level and off from Z2M round-tripped through the MCU.pytest tests: 312 passed. Telink build of the ZDMS16-2 image in CI on my fork.Open questions
U(dimmer power-on DP) andPT(relay power-on DP) do the same job for different outputs, andITuses the Tuya type numbers 1/2/4 whiledp_attributesuse B/E/V. Happy to unify them if you have a preference.src/zigbee/; it could move tosrc/base_components/.