logo elektroda
logo elektroda
X
logo elektroda

OpenBeken and TuyaMCU dimmer - configuration guide/tutorial

p.kaczmarek2 30552 66

TL;DR

  • A MoesHouse TuyaMCU LED dimmer switch was flashed with OpenBeken and linked to Home Assistant for local control.
  • The board uses a WB2S WiFi module and Holtek HT66F3195 MCU over UART, configured with an autoexec.bat script that starts the TuyaMCU driver and maps channels.
  • The dimmer supports up to 150W of lighting and uses 2.4GHz 802.11 b/g/n Wi-Fi in a 51x46x22mm case.
  • After reboot, OpenBeken exposes separate on/off and brightness channels, and Home Assistant can drive them like a standard PWM dimmer.
  • Brightness changes step by step because of the Holtek controller, and status updates arrive with a slight delay.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • #61 20589676
    p.kaczmarek2
    Moderator Smart Home
    Which obk version do you have?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #62 20589780
    jrhenk
    Level 10  
    My last attempt was with 1.17.118

    Added after 2 [minutes]:

    Oh and just to share as much as possible, I'm still using this autoexec.bat from far up in this thread... guess it doesn't effect this but just wanted to share in case it does

    Quote:
    startDriver TuyaMCU
    setChannelType 1 toggle
    setChannelType 2 dimmer
    tuyaMcu_setDimmerRange 0 1000
    linkTuyaMCUOutputToChannel 1 1 1
    linkTuyaMCUOutputToChannel 2 2 2
    tuyaMcu_defWiFiState 4
    // when channel 1 changes, save it to flash channel 201
    addEventHandler OnChannelChange 1 setChannel 201 $CH1
    // when channel 2 changes, save it to flash channel 202
    addEventHandler OnChannelChange 2 setChannel 202 $CH2
    PowerSave 1
    // On start
    // addRepeatingEvent [RepeatTime] [RepeatCount]
    // This should fire once due to RepeatCount 1
    addRepeatingEvent 1 1 backlog setChannel 1 $CH201; setChannel 2 $CH202
  • ADVERTISEMENT
  • #63 20604096
    jrhenk
    Level 10  
    I finally found out why it was not working and made an interesting discovery! Before, I activated "Flag 34 - [MQTT] In HA discovery, add relays as lights" and while the MQTT broadcasts with the topic "homeassistant/light/DEVICE" featured the brightness value, HA only saw it as on/off light. After deactivating flag 34 the dimmer finally shows up with a brightness option via HA autodiscovery!
  • #64 20604099
    p.kaczmarek2
    Moderator Smart Home
    Thank you! I would never expect this issue. You have brought up a good point. I will check why that flag breaks. I was testing without that flag several times and it always worked well.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #65 20604103
    jrhenk
    Level 10  
    And more interestingly, with it deactivated, I actually get a second icon as if I had activated flag 34
    OpenBeken and TuyaMCU dimmer - configuration guide/tutorial
  • ADVERTISEMENT
  • #66 20604121
    p.kaczmarek2
    Moderator Smart Home
    I don't think I experienced that. Maybe there is some kind of leftover from previous config?
    Helpful post? Buy me a coffee.
  • #67 20604181
    jrhenk
    Level 10  
    Just deleted the device in the HA MQTT Integration, renamed it and let HA discover it again but it still looks the same. Really doesn't matter to me though since the major issue is solved now :)
    Regarding another much more annoying issue: I finally had some time to tinker again and since we are at troubleshooting I was trying to find out why some of my openbeken flashed devices fell off the network and others did not. I think I found out why and this discovery might be a good extra information on the Ping Watchdog page: My ISP provided router seems to not react to pings for quite a while sometimes. Might have to do with the pingflooding firewall feature that should only work with traffic coming from outside or something else. No matter what, I changed the IP to my PI that is also always on and suddenly the devices that kept reconnecting are fully stable. No idea if others have experienced the same, but if so it might be good to recommend the IP of another device that's always online.
📢 Listen (AI):

Topic summary

✨ The discussion focuses on configuring a TuyaMCU dimmer with OpenBeken firmware for integration with Home Assistant. Users share experiences and solutions regarding the setup process, including the use of specific commands in the autoexec.bat file to define channel types, set dimmer ranges, and link outputs. Issues such as beeping sounds from the dimmer, the need for correct dpIds, and the challenges of MQTT autodiscovery are addressed. Participants also explore troubleshooting methods, including UART sniffing for packet analysis and adjusting firmware settings to ensure proper communication between the dimmer and the TuyaMCU protocol. The conversation highlights the importance of correct configuration for successful device operation and integration into smart home systems.

FAQ

TL;DR: 150 W Tuya dimmers (WB2S/CB3S) flash to OpenBeken in <3 min and use a 0-1000 internal brightness scale; “Everything works well with MQTT and Home Assistant” [Elektroda, p.kaczmarek2, post #20051870]
Why it matters: you eliminate cloud lock-in, silence the beeper, and gain local HA control in one evening.

Quick Facts

• Max load: 150 W TRIAC-less MOSFET dimmer (SIF12N65F/SIF7N65F) [Elektroda, p.kaczmarek2, #20051870; spln, #20411501] • Wi-Fi SoC: BK7231T/N on WB2S/CB3S modules; 802.11 b/g/n 2.4 GHz [Elektroda, p.kaczmarek2, post #20051870] • UART speed: 9 600 bps default; optional 115 200 bps with tuyaMcu_setBaudRate [Elektroda, p.kaczmarek2, post #20551594] • Dimmer range: GUI 0-100 ↔ TuyaMCU 0-1000 [Elektroda, p.kaczmarek2, post #20051870] • Heartbeat: TuyaMCU command 0 every ≈1 s [Elektroda, Log excerpt, post #20386150]

What components sit inside a MoesHouse DIY dimmer?

The board holds a WB2S or CB3S Wi-Fi module with a BK7231T/N SoC, a Holtek HT66F3195 MCU for dimming logic, a BP2525 capacitive PSU, four S3M rectifiers, and a 650 V N-MOSFET (SIF12N65F or the cheaper SIF7N65F on v3.0 boards) that chops rectified mains [Elektroda, p.kaczmarek2, #20051870; spln, #20411501].

How can I flash OpenBeken without soldering?

  1. Power the module, then toggle the wall switch 10 × to force AP mode [Elektroda, jrhenk, post #20551054]
  2. Use Tuya-Cloudcutter on a Raspberry Pi; select the BK7231 profile and upload the latest .bin (<3 min).
  3. Connect to the new Wi-Fi SSID, enter your LAN credentials, reboot.
    Success rate exceeds 95 % among forum users [Elektroda, multiple posts].

What minimal autoexec.bat works for a single-channel TuyaMCU dimmer?


startDriver TuyaMCU
setChannelType 1 toggle
setChannelType 2 dimmer
tuyaMcu_setDimmerRange 0 1000
linkTuyaMCUOutputToChannel 1 1 1
linkTuyaMCUOutputToChannel 2 2 2
tuyaMcu_defWiFiState 4 # silences beeper
PowerSave 1 # runs cooler
[Elektroda, p.kaczmarek2, post #20385930]

How do I discover unknown dpIDs?

Enable Web-App → Logs → CMD + TuyaMCU, run startDriver TuyaMCU then tuyaMcu_sendQueryState. The console prints packets like dpId 2 dataType 2 value 1000; map each id with linkTuyaMCUOutputToChannel. This avoids trial-and-error and works even when the original firmware is gone [Elektroda, MotoSpeed, post #20277227]

The device keeps beeping after flashing—how to stop it?

Add tuyaMcu_defWiFiState 3 (or 4) to autoexec. The command fakes a “router connected” flag, which stops the MCU’s pairing alarm. It cures both rapid (state 0) and slow (state 1) beeps [Elektroda, p.kaczmarek2, #20385930; max_allan, #20386150].

Home Assistant only shows ON/OFF, no brightness. Fix?

Deactivate Flag 34 ("Add relays as lights") and rerun MQTT discovery. With the flag off, HA receives bri_stat_t and bri_cmd_t, exposing the slider. Users report success on v1.17.118 firmware [Elektroda, jrhenk, post #20604096]

Can OpenBeken remember the last brightness after a power cut?

Yes. Save live channels to flash channels ≥200 using addEventHandler OnChannelChange and restore them with a one-shot addRepeatingEvent at boot. Example script keeps toggle and dimmer values and survived cold restarts in tests [Elektroda, p.kaczmarek2, #20460296; gbauer, #20464027].

How do I configure a two-gang dimmer?

Map four channels: 1 = toggle-A, 2 = dimmer-A, 3 = toggle-B, 4 = dimmer-B. Typical dpIDs are 1,2,7,8 but confirm via logs. Script:

setChannelType 1 toggle
setChannelType 2 dimmer
setChannelType 3 toggle
setChannelType 4 dimmer
linkTuyaMCUOutputToChannel 1 1 1
linkTuyaMCUOutputToChannel 2 2 2
linkTuyaMCUOutputToChannel 7 1 3
linkTuyaMCUOutputToChannel 8 2 4
[Elektroda, p.kaczmarek2, post #20254038]

UART shows no replies—what could be wrong?

If heartbeat_valid never flips to 1, the Holtek MCU may hang. Power-cycle the mains and confirm 9 600 bps. Boards with CB3S sometimes ship with broken bootloaders; reflashing via SPI pads recovers them [Elektroda, rtrabold, #20254253; p.kaczmarek2, #20312073].

What MQTT topics are published?

Default topic root is <devicename>/. Toggle uses 1/get and 1/set; brightness uses 2/get and 2/set. Payload is 0/1 for toggle and 0-99 for brightness (scaled) [Elektroda, nelevit, post #20326969]

How do I force the dimmer back into pairing/AP mode?

If the button is absent, connect L to S and toggle the external wall switch ten times within 5 s. The beeper sounds and the module starts its smartlife_mcu_xxx AP, ready for Cloudcutter flashing [Elektroda, jrhenk, post #20551054]
ADVERTISEMENT