logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken

PSlowik 3708 18
Best answers

How do I configure OpenBeken after flashing a BK7231T MOES WS-EUB TuyaMCU switch so the relay works and the front LED stops blinking?

Add an autoexec.bat in LittleFS/Open Web Application, then put `startDriver TuyaMCU`, `setChannelType 1 toggle`, and `linkTuyaMCUOutputToChannel 1 bool 1` into it, save, and reboot; this creates a GUI button that controls the relay on a single-button switch [#20536983] If the front LED keeps blinking because the MCU thinks it is not paired, add `tuyaMcu_defWiFiState 4` at the end of autoexec.bat to make the MCU report Wi‑Fi/cloud connected and calm the LED [#20537015] OpenBeken can also work with MQTT, and from the later update Home Assistant Discovery supports TuyaMCU toggle channels automatically, so you do not need to write YAML by hand anymore [#20537113][#20562539]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20536765
    PSlowik
    Level 12  
    Posts: 80
    Rate: 2
    Hello and welcome

    I have a pair of MOES lighting switches, model WS-EUB, purchased from ali, I would like to get rid of the tuya, so thanks to the help of p.kaczmarek2, I uploaded soft BK7231T via UART.
    The soft uploaded wifi I put it on my WIFI but I got stuck at the stage of setting this BK :(

    the LED on the front panel of the switch is blinking all the time now :(
    On org software, I attach it below, it flashed until it was paired with the tuya app.

    Could you please advise what to do next?

    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken


    I am also attaching the log
    Attachments:
    • logtuyamcu.txt (14.06 KB) You must be logged in to download this attachment.
    • readResult_BK7231T_QIO_2023-10-4--18-51-46.rar (970.6 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #2 20536828
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    At this point, you're already up and running TuyaMCU - startDriver TuyaMCU in autoexec.bat, right?
    If not, then in Open Web Application, in LittleFS, do autoexec.bat and there enter "startDriver TuyaMCU" so that it starts automatically at system startup. Do a reboot.

    I also see you posted the log:
    
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 07 00 08 07 02 00 04 00 00 00 00 1B 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 7, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 07 00 05 01 01 00 01 01 0F 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 7 (State) with 12 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 1, dataType 1-DP_TYPE_BOOL and 1 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte: 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01 
    

    this log shows the dpID of the variables responsible for the relays/buttons, but it's in such a form that I don't know what is what.

    Can you do the following test:
    1. In Web App Logs, clear the log
    2. Press the first touch button
    3. Copy this web app log, and note which ones dpID from the log corresponds to him
    4. Repeat steps 1 2 and 3 for each touch button

    The pictures don't show how many buttons it has. Four touch buttons? Two?
    Helpful post? Buy me a coffee.
  • #3 20536904
    PSlowik
    Level 12  
    Posts: 80
    Rate: 2
    As for LittleFS, I don't know what it is, where it is etc :/

    The on/off switch is just a single button physical button



  • Helpful post
    #4 20536983
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    Autoexec is created here:
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken

    here "Create file":
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
    since you say only one button, I think I already know how to configure it

    In autoexec.bat paste:
    
    startDriver TuyaMCU
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    

    save, reboot. You should get a button on the GUI that controls the relay. Check.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20537010
    PSlowik
    Level 12  
    Posts: 80
    Rate: 2
    I confirm there is a button and it reacts like pressing the keys on the plate lighting up green or the relay is working I don't know yet because the mammpkytki are fully assembled but I will test it soon.
    But what to do with the LED that blinks all the time ...?
    In tuya it worked so that if the light was not turned on, the diode barely shines and when the light is turned on, the diode starts to shine strongly ...
    And now it's blinking...
  • Helpful post
    #6 20537015
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    Most likely the LED indicates that the MCU thinks it is not paired. OpenBeken defaults to the "paired" state when you also connect MQTT, but if you want a shortcut and silence the LED, try adding the following to autoexec at the end:
    tuyaMcu_defWiFiState 4
    This will set the MCU's WiFi state to 4, which is "connected to router and to cloud", and should calm the LED down.

    You can find the command documentation here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md

    Unless it's about another diode, then we'll think about it.
    Helpful post? Buy me a coffee.
  • #7 20537036
    PSlowik
    Level 12  
    Posts: 80
    Rate: 2
    haha it actually worked the diode reacts perfectly, now just some MQTT and then recommends 2-button switches :) )

    Do you have to recreate the autoexec every time you run it? because it disappears after reboot

    I confirm the relay is working, the light is on :D
    You are great!

    Now spr to set mqtt because OpenBK is probably not integrated with HA??
  • #8 20537113
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    For normal devices there is automatic HA discovery where everything happens by itself:
    https://www.youtube.com/watch?v=pkcspey25V4&ab_channel=Elektrodacom
    This way you can pair a lot and everything configures itself.

    Unfortunately, your device is weird by the manufacturer - I don't know why it needs TuyaMCU and UART control to control ONE relay and you have to write the Yaml code for it manually.

    Start by configuring MQTT in Configure MQTT. On the web panel, the MQTT status should be connected.
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken


    Then in Home Assistant add the device via configuration.yaml:
    Code: YAML
    Log in, to see the code

    change the names of course, I'm testing on a simulator on windows. You will have a different name than me, you will probably enter something else as "Client Topic" (I have WindowsOBK there)
    Helpful post? Buy me a coffee.
  • #9 20538497
    PSlowik
    Level 12  
    Posts: 80
    Rate: 2
    :) :) :)
    It worked :) :) I'm really glad…

    It will still help if I put soft on the 2-button switch ;) if I can.

    Please tell me how is the overall stability of this software? Much better because it doesn't work in the cloud...

    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
  • ADVERTISEMENT
  • #10 20538784
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    Remember to enable autoexec too startDriver SSDP for Windows to see devices:
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken

    Stability test showed it can run for months, here is a screenshot of the status as of January 11, 2023 :
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken
    Uptime 46 days
    MOES 1-2 Light Switch: WB2S BK7231T TuyaMCU configuration for OpenBeken

    Recently, we have additionally enabled the watchdog to be able to automatically restart the software in the event of a possible suspension of the software


    soft with two buttons probably similarly only you set 2 toggles and map two TuyaMCU variables, probably ID 1 and 2
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #11 20562539
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14637
    Help: 655
    Rate: 12649
    UPDATE 2023-05-01

    From today, Home Assistant Discovery also works for Toggle channels from TuyaMCU. This means you don't have to write YAML by hand anymore.

    Configuration below:
    p.kaczmarek2 wrote:

    In autoexec.bat paste:
    
    startDriver TuyaMCU
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    

    save, reboot. You should get a button on the GUI that controls the relay. Check.

    It is seen by Home Assistant Discovery and can be added automatically to the HA.
    Helpful post? Buy me a coffee.
  • #12 21359163
    styb113
    Level 4  
    Posts: 5
    Hello,
    I have a similar device to this one with 3 buttons and relays. It also has RF functionality. If I flash it with OpenBK how do I have to configure the settings for the TUYA MCU?
    Printed circuit board with a communication module and electronic components.
    Printed circuit board with three buttons and contacts on a white background.
  • Need to map LED GPIO or Tuya DP to relay state

    #13 21909533
    PullScanner1
    Level 3  
    Posts: 4
    bonjours, j’utilise OpenBK7231T sur un interrupteur Tuya (BK7231T + MCU Tuya).
    Le relais fonctionne correctement et est bien piloté via TuyaMCU + MQTT + Home Assistant.
    Configuration actuelle :
    startDriver TuyaMCU
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    MQTT OK (publication et contrôle depuis HA OK)
    tuyaMcu_defWiFiState 4

    mon problème ( enfin si on peut dire que s'est un probléme ) le relais fonctionne parfaitement, le bouton physique est OK (retour état id 1)
    MQTT remonte correctement dans HA, mais la LED reste allumée en permanence, indépendamment de l’état ON/OFF du relais
    mon hypothèse LED non mappée à un GPIO OpenBK ou LED pilotée en inverse / mal configurée
    ou LED liée à un autre DP ID Tuya non encore mappé

    mon objectif trouver le GPIO LED ou DP correspondant
    lier la LED au channel du relais pour synchronisation état ON/OFF,
    merci de votre aide.
  • #14 21909564
    divadiow
    Level 38  
    Posts: 5074
    Help: 441
    Rate: 898
    PullScanner1 wrote:
    but the LED remains permanently lit, regardless of the ON/OFF state of the relay


    did you take a backup of the original Tuya firmware?
  • #15 21909582
    PullScanner1
    Level 3  
    Posts: 4
    désoler mais non je n'est pas fait de copie du firmware original
  • Tuya schema may reveal remaining dpIDs

    #16 21909586
    divadiow
    Level 38  
    Posts: 5074
    Help: 441
    Rate: 898
    OK, no worries. The Tuya config data may still be present and downloadable. We should be able to get any remaining dpIDs from the schema, assuming the product key is shown in the extraction.

    Screenshot of OpenBK dashboard with three OFF channels and buttons Plug, USB1, USB2

    open the saved file in Easy Flasher

    Screenshot of BK7231 Easy UART Flasher showing extracted JSON config and a text description panel.

    you may need to remove any saved wifi credentials from the json before posting the output, if you paired device with Tuya app ever. Credentials may be in base64
  • #17 21909603
    PullScanner1
    Level 3  
    Posts: 4
    J'ai effectué la manipulation dans OBK, mais cela m'indique que tout est effacé. Par contre, il y a eu une évolution depuis hier : la LED du bouton clignote au démarrage, comme pour se connecter au Wi-Fi (donc normal), puis elle reste constamment éteinte lors de l'appui sur le bouton ON/OFF. (Je suis débutant.)
  • #18 21909618
    divadiow
    Level 38  
    Posts: 5074
    Help: 441
    Rate: 898
    send command
    tuyaMcu_sendQueryState
    from the logs tab in the web app. do you get a list of dpIDs and a product code returned?
  • Power cycle required for TuyaMCU LED sync

    #19 21909661
    PullScanner1
    Level 3  
    Posts: 4
    Après quelques recherches sur ce site, j’ai découvert un fichier autoexec.bat que j’ai téléversé (fichier original).
    La configuration des LED était la suivante :

    LED1 : verte (Wi-Fi)
    LED2 : bleue (état relais)

    Configuration initiale du fichier :

    startDriver TuyaMCU
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    tuyaMcu_defWiFiState 4


    Le relais fonctionnait correctement, mais la LED1 (Wi-Fi) ne s’activait pas.

    Ensuite, avec un peu d’aide et une modification du fichier autoexec.bat, j’ai fait une découverte intéressante.
    Après avoir téléversé le fichier modifié et redémarré l’appareil, rien ne semblait fonctionner au départ.

    En revanche, après avoir débranché l’appareil, attendu 2 à 3 minutes, puis l’avoir rebranché, le comportement a changé :

    La LED1 Wi-Fi s’est mise à clignoter correctement lors de la connexion
    Elle s’est ensuite éteinte une fois la connexion Wi-Fi établie
    La LED2 est désormais synchronisée avec l’état du relais

    Voici le fichier autoexec.bat modifié :

    startDriver TuyaMCU
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    
    linkTuyaMCUOutputToChannel 2 bool 16
    
    tuyaMcu_defWiFiState 4


    Si cela peut aider certaines personnes

Topic summary

✨ The discussion focuses on configuring MOES WS-EUB 1-2 light switches with BK7231T chips using OpenBeken firmware to replace the original Tuya cloud-dependent software. After flashing the BK7231T via UART, the LED on the switch blinks continuously, indicating the MCU is not paired. The solution involves creating an autoexec.bat file in LittleFS with commands to start the TuyaMCU driver, set the channel type to toggle, and link the TuyaMCU output to the channel. Adding the command "tuyaMcu_defWiFiState 4" in autoexec.bat sets the WiFi state to connected, stopping the LED blinking. The relay functionality is confirmed working, and MQTT integration with Home Assistant (HA) is discussed, including manual YAML configuration and recent updates enabling automatic HA discovery for TuyaMCU toggle channels. Stability tests show the firmware can run for months with watchdog support for automatic restarts. For two-button switches, similar configuration applies by setting two toggles and mapping TuyaMCU variables. The thread also briefly mentions a 3-button RF device and queries about its TuyaMCU configuration under OpenBK.
Generated by the language model.

FAQ

TL;DR: 46-day uptime observed and “Stability test showed it can run for months.” Configure TuyaMCU via autoexec to map dpIDs, stop blinking LEDs, and enable HA Discovery for MOES BK7231T switches. This FAQ helps MOES WB2S owners replace Tuya, fix LED blinking, and integrate with MQTT/HA. [Elektroda, p.kaczmarek2, post #20538784] Why it matters: You get local control, fast response, and cloud-free Home Assistant integration for MOES WB2S/BK7231T switches.

Quick Facts

How do I start TuyaMCU and get a working GUI button on OpenBeken?

Create autoexec.bat and add: startDriver TuyaMCU, setChannelType 1 toggle, linkTuyaMCUOutputToChannel 1 bool 1. Save and reboot. You’ll see a button on the web UI that toggles the relay. This maps the TuyaMCU boolean dpId to Channel 1 as a Toggle. [Elektroda, p.kaczmarek2, post #20536983]

Where do I create autoexec.bat so settings persist?

Open the Web App, go to LittleFS, choose Create file, name it autoexec.bat, paste your commands, then Save. Reboot to apply. Using LittleFS ensures the file persists across restarts and runs on boot. [Elektroda, p.kaczmarek2, post #20536983]

The front LED keeps blinking after flashing—how do I stop it?

Set the MCU’s Wi‑Fi state with tuyaMcu_defWiFiState 4. This tells the TuyaMCU it is connected to the router and cloud, which stops the pairing blink pattern. “4” reflects a fully connected state. [Elektroda, p.kaczmarek2, post #20537015]

How do I find the TuyaMCU dpIDs for my buttons or relays?

Use the Web App Logs to identify dpIDs.
  1. Clear the log.
  2. Press one touch button and observe the State message with dpId.
  3. Repeat for each button and note dpIDs for mapping. [Elektroda, p.kaczmarek2, post #20536828]

How do I configure a two‑button MOES switch?

Add lines to autoexec: setChannelType 1 toggle; setChannelType 2 toggle; linkTuyaMCUOutputToChannel 1 bool ; linkTuyaMCUOutputToChannel 2 bool . Replace with your IDs. As the expert noted, “set 2 toggles and map two TuyaMCU variables, probably ID 1 and 2.” [Elektroda, p.kaczmarek2, post #20538784]

How do I configure a three‑button switch (even if it has RF)?

Repeat the pattern for three channels in autoexec: setChannelType 1/2/3 toggle; then linkTuyaMCUOutputToChannel 1/2/3 bool <dpId1/2/3>. Replace placeholders with your MCU dpIDs. Reboot and verify three toggles in the web UI. [Elektroda, p.kaczmarek2, post #20536983]

Does Home Assistant auto‑discovery work with these TuyaMCU toggles?

Yes. From 2023‑05‑01, Toggle channels exposed via TuyaMCU are auto‑discovered by Home Assistant. You only need to configure MQTT on the device; no YAML is required. Devices will appear in HA after restart. [Elektroda, p.kaczmarek2, post #20562539]

How do I add the switch to Home Assistant manually with MQTT/YAML?

In configuration.yaml, define an MQTT switch with state_topic /1/get, command_topic /1/set, payload_on 1, payload_off 0, qos 1, retain true, and availability topic /connected. Set a unique_id and name. Replace with your device Client Topic. [Elektroda, p.kaczmarek2, post #20537113]

How do I set up MQTT on the OpenBeken device?

Open Configure MQTT on the web UI, enter broker address, client, username, and password, then Save. Confirm the MQTT status shows Connected on the panel before testing Home Assistant or scripts. [Elektroda, p.kaczmarek2, post #20537113]

How can Windows discover my OpenBeken devices on the network?

Enable SSDP by adding startDriver SSDP to autoexec.bat and reboot. This allows Windows to see and list the device via network discovery tools. It eases device management on a PC. [Elektroda, p.kaczmarek2, post #20538784]

Is OpenBeken stable on BK7231T hardware?

Yes. A long‑run test showed 46 days of uptime, and a watchdog now auto‑restarts on faults. As the expert said, “Stability test showed it can run for months.” These measures support reliable, always‑on control. [Elektroda, p.kaczmarek2, post #20538784]

Why does my single‑relay MOES use TuyaMCU over UART?

Some manufacturers route even one relay through a TuyaMCU, so you control it via dpIDs. The expert noted your model is unusual: “your device is weird... needs TuyaMCU and UART to control ONE relay,” which required manual YAML before Discovery improved. [Elektroda, p.kaczmarek2, post #20537113]

Where is the official OpenBeken command documentation?

See the command reference in the OpenBeken docs README linked by the maintainer. Use it to look up drivers, TuyaMCU commands, and examples for autoexec.bat. [Elektroda, p.kaczmarek2, post #20537015]
Generated by the language model.
ADVERTISEMENT