logo elektroda
logo elektroda
X
logo elektroda

WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone

Porkoltszaft 2829 9
ADVERTISEMENT
  • #1 20631574
    Porkoltszaft
    Level 3  
    Greetings!

    I purchased two wireless Tuya-based doorbells from Aliexpress (WGH-ML-001). I knew it has a Tuya CBU module (see pictures).

    WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone

    WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone

    I flashed OpenBeken to one of the devices, after sniffed the UART communication.
    To flash the image, I had to remove the module, because the TuyaMCU littered the TX/RX lines. I attached the original firmware to my post.

    Here are my findings:

    I can PREVIEW the volume and the ringtone by sending the following commands in the command line:
    - tuyaMcu_sendState 3 2 100 (for the volume, values are from 1 to 100)
    - tuyaMcu_sendState 2 2 14 (for the ringtone, values are from 1 to 40)

    However, these commands do not SAVE the settings. For that, the UART communication is the following:
    
    Sent by WiFi module:
    55 AA	00	06		00 11	0100000D0404010C014700FF04FEFF0031	B2	
    HEADER	VER=00	Unk		LEN	fnId=1 Raw V=04 04 01 0C 01 47 00 FF 04 FE FF 00 31	CHK	                                                                                                                         
    


    In that, the
    - 7th byte (0x00) is the mode (00 = sound&light / 01 = just sound / 02 = just lights)
    - 6th byte (0x47) is the volume (from 1 to 100 in hex)
    - 5th byte (0x01) is the ringtone (from 1 to 40 in hex)

    My first question is, how can I send this RAW data to the TuyaMCU? It works if I use the "uartSendHex" but I cannot make it work with tuyaMCU_sendState. Also, how can I bind these settings to for example dimmers? (one with 1-100 range, and one with 1-40 for the ringtone)?
    Keep in mind, after selecting, you must send the last message, otherwise the settings will not save (just preview).

    My other question is: After pressing the doorbell button, the WiFi module receives the following on UART:
    
    Received by WiFi module:
    55 AA	03	07		00 05	0A 01 00 01 01 		1B	
    HEADER	VER=03	State		LEN	fnId=10 Bool V=1	CHK	
    
    Received by WiFi module:
    55 AA	03	07		00 08	05 00 00 04 FEFF0031 		48	
    HEADER	VER=03	State		LEN	fnId=5 Raw V=-16842703	CHK
    


    How can I bind this to a button? (to use in home assistant -> I want to log when was the button pressed, and I want to send a push notification to my phone). This is the important bit, I really do not care if I can't set the volume or the ringtone (however, they may come in handy if you, for example, want to silence the doorbell after 21:00 with an automation or when you want to sleep).
    Or can I send the command over http to Openbeken (in this case I will construct the raw data, calculate checksum and send over http with uartSendHex)?

    If this can't be done out-of-the-box, can you point me to a tutorial to write my own driver for this?

    Thank you very much, and sorry for my English, I hope you can understand what I'm after. Also, sorry if I made mistakes in the post creation, this is my first post here.

    EDIT:

    Okay, so I fiddled with the thing all day long, and I got the pushbutton to work. I'm sure this is not the best way to do it, but it works.

    I added the following to the autoexec.bat:
    
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 10 1 1
    AddChangeHandler Channel1 == 1 startScript resetButton.bat * 1
    


    This links the tuyaMCU to Channel1. But the toggle button never changes back to "OFF" because the UART message from TuyaMCU always has the value "1". So I wrote a script 'resetbutton.bat', and we run it whenever the button value changes to '1'.

    The resetbutton.bat:
    
    delay_s 5
    ToggleChannel 1
    return
    


    This waits 5 seconds, and then toggles back the channel to '0'.

    Then, I set up MQTT and integrated the button in Home Assistant. Now I know when the doorbell was pressed, and I can send notifications to my phone, or do other stuff via automations.

    If you have a more elegant solution to this, please share it.
    Also, my other questions are still on (how to deal with changing the volume and the ringtone). It would be nice to have the option to set these from HA.

    David
  • ADVERTISEMENT
  • #2 20632163
    p.kaczmarek2
    Moderator Smart Home
    You have a very interesting device which is a totally new thing to me. I haven't seen such one yet. I don't think there is any scriptable solution for that at the moment, because the packet data format seems custom to your appliance.

    We have a basic ability to put channel value into a single byte string, so I think with little adjustments I could add some kind of mechanism for you to send the raw packet data. I have used something similar here (warning, not yet translated topic):
    https://www.elektroda.pl/rtvforum/topic3985978.html

    You've given such packet format:
    
    Sent by WiFi module:
    55 AA	00	06		00 11	0100000D0404010C014700FF04FEFF0031	B2	
    HEADER	VER=00	Unk		LEN	fnId=1 Raw V=04 04 01 0C 01 47 00 FF 04 FE FF 00 31	CHK	                                                                                                                         
    
    In that, the
    - 7th byte (0x00) is the mode (00 = sound&light / 01 = just sound / 02 = just lights)
    - 6th byte (0x47) is the volume (from 1 to 100 in hex)
    - 5th byte (0x01) is the ringtone (from 1 to 40 in hex)
    

    Maybe I can add some command like that:
    
    tuyaMcu_sendState idk idk idk 04 04 01 0C $CH9$ $CH10$ $CH11$ FF 04 FE FF 00 31
    

    that would allow you to send RAW data taken from channel values. Then you could just use scripting/channel types to get data from UI.

    What do you think, would such a command suit your needs?

    Btw, regarding the second part of your message, why not:
    
    AddChangeHandler Channel1 == 1 addRepeatingEvent 5 1 setChannel 1 0
    

    
    addRepeatingEvent	[IntervalSeconds][RepeatsOr-1][CommandToRun]
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20632834
    Porkoltszaft
    Level 3  

    Thank you so much for your fast reply!

    Yes, I think your proposal will work for this device. I translated the article you mentioned, I did not know you can place variables in the uartSendHex parameter, it's very cool!

    For the doorbell button, your one-liner script works, thank you! :) I overcomplicated a bit.
  • #4 20635059
    ferbulous
    Level 18  
    Hi @Porkoltszaft which battery does the transmitter use?

    @p.kaczmarek2 what do you think about wifi video camera doorbell? is this supported by openbeken?
  • #5 20635148
    Porkoltszaft
    Level 3  

    Hi!

    The transmitter (doorbell button) has no battery. It self-powers when you press the button (it has a nice click to it. I think it pushes a magnet through coils and this powers the circuit). The AliExpress listing claimed it has an IP44 rating, but I doubt this... It's definitely not protected against moisture so I don't know how much it will last outdoors.

    WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone
  • ADVERTISEMENT
  • Helpful post
    #6 20635354
    p.kaczmarek2
    Moderator Smart Home

    Okay, so I've added the feature you requested, along with a self-test for OpenBeken simulator.
    Code: C / C++
    Log in, to see the code

    Here's how to use:
    
    tuyaMcu_sendState 17 0 $CH10$ $CH10$ $CH11$ $CH2$ $CH3$ 01 00 $CH4$ 04 01 00 A0 08 00 00 32
    tuyaMcu_sendState [dpID] [dpType] [dpValue]
    

    Available dptypes:
    Code: C / C++
    Log in, to see the code


    Following command will automatically add TuyaMCU header, type, etc, along with a correct checksum.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20641322
    Porkoltszaft
    Level 3  
    Hi @p.kaczmarek2 !

    Thank you so much for adding this feature! It works!

    I have now the following in autoexec.bat:
    
    // initial setup
    startDriver NTP
    ntp_timeZoneOfs 02:00
    startDriver TuyaMCU
    setChannelType 1 toggle
    SetChannelLabel 1 button
    setChannelType 2 dimmer
    SetChannelLabel 2 ringtone
    setChannelType 3 dimmer
    SetChannelLabel 3 volume
    setChannelType 4 toggle
    SetChannelLabel 4 dnd
    // link doorbell button to channel 1, and after pressing it, set it back to 'off' / 0
    // this is needed because TuyaMCU always sends '1' on button press, and never toggles it back automatically.
    linkTuyaMCUOutputToChannel 10 1 1
    AddChangeHandler Channel1 == 1 addRepeatingEvent 5 1 setChannel 1 0
    // link volume and ringtone slider to the channels, so you can immediatelly hear, what you select
    linkTuyaMCUOutputToChannel 3 2 3
    linkTuyaMCUOutputToChannel 2 2 2
    
    // If the value of the "volume" or "ringtone" slider changes, save it.
    addEventHandler OnChannelChange 2 backlog ClampChannel 2 1 40; tuyaMcu_sendState 1 0 04 04 01 0C $CH2$ $CH3$ 00 FF 04 FE FF 00 31;
    addEventHandler OnChannelChange 3 backlog ClampChannel 3 1 100; tuyaMcu_sendState 1 0 04 04 01 0C $CH2$ $CH3$ 00 FF 04 FE FF 00 31;
    
    // Setup DND toggle button. If DND is enabled, only the lights flash on the doorbell after pressing the button.
    AddChangeHandler Channel4 == 1 tuyaMcu_sendState 1 0 04 04 01 0C $CH2$ $CH3$ 02 FF 04 FE FF 00 31
    AddChangeHandler Channel4 == 0 tuyaMcu_sendState 1 0 04 04 01 0C $CH2$ $CH3$ 00 FF 04 FE FF 00 31
    
    tuyaMcu_defWiFiState 4
    


    I also set '-1' to channels 2, 3, 4 in "Config -> Configure startup", to remember the ringtone, volume and DND state after rebooting or when the power goes out.

    I have one more question: Is it possible to limit the sliders minimum/maximum values? I found the "ClampChannel" command, with that, I can filter the values which are out of bounds (not to send garbage to the MCU). But it would be nicer, to have one slider which goes from 1 to 40 (this is the ringtone range) and one which goes from 1-100. I found "tuyaMcu_setDimmerRange" but with this, can I limit only one of the sliders (in the parameters there are no channel ID)? Or should I use "Map" command? Unfortunately I'm a little lost in the documentation, I'm not sure what parameter is what (for examaple Map 2 $CH2$ 0 100 1 40 would work in my case? Or what is "inputValue"? )

    Thank you very much for your help, awesome work!
  • #8 20642044
    p.kaczmarek2
    Moderator Smart Home

    Maybe you would benefit more from making a custom device page hosted in LittleFS?

    Here's a sample page:
    WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone

    Here are some topics about it, but one is not translated yet.
    https://www.elektroda.pl/rtvforum/topic3987582.html#20642035
    https://www.elektroda.com/rtvforum/topic3971355.html
    Helpful post? Buy me a coffee.
  • #9 20644304
    Porkoltszaft
    Level 3  

    Thank you very much, you always learn new things! I did not know you can make custom HTML pages hosted on these things. This is great!

    I also got it to work with Home Assistant, so the custom page might not be necessary, but I will experiment with that too.

    WGH-ML-001 Tuya Wireless Doorbell: Flashing OpenBeken, Adjusting Volume & Ringtone

    I created 4 input number helpers (2 for volume, 2 for ringtone since I have 2 receiver units). This way I can set different volumes and ringtones for each area. Also, HA allows me to set the slider min/max values.
    Then I created automations for each slider and send their values over MQTT to OpenBeken, like this:
    
    trigger:
      - platform: state
        entity_id: input_number.csengo_2_csengohang
      condition: []
      action:
      - service: mqtt.publish
        data:
          topic: wificsengok_2/2/set
          payload: '{{ states(''input_number.csengo_2_csengohang'') | int }}'
      mode: single
    


    I'm very happy to - with your help and work - achieve a cloudless solution. Thank you for developing this great firmware.
  • #10 20644671
    p.kaczmarek2
    Moderator Smart Home

    Thanks! If you have any other devices, not necessarily Beken (even ESP is welcome here), feel free to post the teardowns as well.
    We're still extending our list:
    https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the WGH-ML-001 Tuya Wireless Doorbell, focusing on flashing OpenBeken firmware and adjusting volume and ringtone settings. The user successfully flashed OpenBeken after addressing UART communication issues caused by the TuyaMCU. Commands for previewing volume and ringtone were shared, but saving these settings required specific UART communication. Community members contributed by suggesting enhancements to the firmware, including a self-test feature and custom device pages. The doorbell button is self-powered, and the user integrated the device with Home Assistant for enhanced control, allowing for different volume and ringtone settings across multiple receivers.
Summary generated by the language model.
ADVERTISEMENT