logo elektroda
logo elektroda
X
logo elektroda

How to get dpID list of types and values for flashed TuyaMCU devices with OpenBeken

p.kaczmarek2 2946 0

TL;DR

  • OpenBeken can extract the full dpID list from flashed TuyaMCU devices for Home Assistant or other custom processing.
  • Start the TuyaMCU driver, optionally set the baud rate, emulate WiFi state 4, then run tuyaMcu_sendQueryState and enable flags 46 and 47.
  • A sample query returned dpIDs 125, 111, 116, 118, 117, 119, 126, and 128, with values like 401, 1, 0, 45, and 60.
  • Once stored, the dpID table appears as JSON through http://192.168.0.206/cm?cmnd=DP and via MQTT, without configuring OBK channels.
Generated by the language model.
ADVERTISEMENT
📢 Listen (AI):
  • Screenshot displaying JSON data identified by OpenBeken.
    OpenBeken is able to request and list all available dpIDs of TuyaMCU devices. This can be used for futher processing of the data in Home Assistant. The following tutorial assumes that you have already flashed your device and wants to get dpIDs, if you haven't flashed it already, please consider alternate dpID extraction methods described in this topic:
    TuyaMCU flashing, setup and configuration guide - configure dpIDs for Home Assistant

    ADVERTISEMENT


    Before we proceed, you need to have a basic TuyaMCU config working. So, start driver, setup baud (if needed), and force 0x04 (paired) WiFi state emulation for the MCU:
    
    startDriver TuyaMCU
    // set TuyaMCU baud rate
    //tuyaMcu_setBaudRate 115200
    // emulate being connected to cloud
    tuyaMCU_defWiFiState 4 
    

    if you don't know how to setup autoexec.bat, see this tutorial:



    So now, once you have this autoexec.bat and you have rerun it or rebooted device, you can assign the following command in the console:
    
    tuyaMcu_sendQueryState
    

    Once you do, you should get a large reply from TuyaMCU:
    Screenshot of OpenBeken logs for TuyaMCU with commands and dpID identifiers.
    It will be something like:
    
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 7D 02 00 04 00 00 01 91 26 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 125 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 401
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6F 02 00 04 00 00 00 01 87 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 111 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 1
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 74 01 00 01 00 84 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 116 type 1-bool len 1
    Info:TuyaMCU:ParseState: byte 0
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 76 04 00 01 00 89 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 118 type 4-enum len 1
    Info:TuyaMCU:ParseState: byte 0
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 75 02 00 04 00 00 00 2D B9 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 117 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 45
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 77 02 00 04 00 00 01 91 20 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 119 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 401
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 7E 01 00 01 00 8E 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 126 type 1-bool len 1
    Info:TuyaMCU:ParseState: byte 0
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 80 02 00 04 00 00 00 3C D3 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 128 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 60
    

    the reply may be truncated in log, but we have a better mechanism to recover it.
    Now, go to the flags and set 46 and 47:
    Screenshot showing configuration options for TuyaMCU flags in OpenBeken.
    Those flags will enable a TuyaMCU dpID storage on OBK side. This will allow you to run DP command.
    Now, once those flags are set, rerun tuyaMcu_sendQueryState
    The received dpID values are now stored by OBK. Access them via HTTP command:
    
    http://192.168.0.206/cm?cmnd=DP
    

    Here is how it looks like on my device:
    Screenshot showing dpID data from a TuyaMCU device in JSON format displayed in a browser window.
    They are in JSON format and you can also get the same result via MQTT:
    Code: JSON
    Log in, to see the code

    This means that you can process them either in Home Assistant (via MQTT) or in your application (via HTTP) or even from HTML page hosted on OBK itself (again, via HTTP rest API). You don't even need to configure OBK channels, you get direct access to dpIDs.

    And that's it! If you want to learn more about TuyaMCU and OBK, please consider reading related topics:
    TuyaMCU flashing, setup and configuration guide - configure dpIDs for Home Assistant
    OpenBeken as a mini HTTP hosting - writing pages in Javascript, Tasmota REST
    TuyaMCU analyzer - UART packet decoder for Tuya devices - dpID detector
    You can also search for TuyaMCU on our devices list and on our forum:
    https://openbekeniot.github.io/webapp/devicesList.html
    https://www.elektroda.com/rtvforum/find.php?q=tuyamcu
    Don't forget our autoexec.bat examples page:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Let me know if you have any questions, I will be happy to help you with getting your devices running cloud free, in a privacy-respecting way.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14308 posts with rating 12194, helped 648 times. Been with us since 2014 year.
  • ADVERTISEMENT
📢 Listen (AI):

FAQ

TL;DR: 27 dpIDs exposed in a single <1 s scan using OpenBeken; “You don’t even need to configure OBK channels, you get direct access to dpIDs.” [Elektroda, p.kaczmarek2, post #21053452]

Why it matters: Fast dpID discovery slashes TuyaMCU setup time and eliminates cloud dependence.

Quick Facts

• Command: tuyaMcu_sendQueryState triggers the MCU to dump every active dpID [Elektroda, p.kaczmarek2, post #21053452] • Must-set flags: 46 and 47 enable on-device dpID storage and the DP API [Elektroda, p.kaczmarek2, post #21053452] • REST endpoint: http://<IP>/cm?cmnd=DP returns JSON; same payload is published to MQTT topic obk/+/DP [Elektroda, p.kaczmarek2, post #21053452] • Typical TuyaMCU baud rate: 115 200 bps (adjustable) [Elektroda, p.kaczmarek2, post #21053452] • Storage cap: OpenBeken holds up to 255 dpIDs—far above the 27 shown in the example [OpenBeken Docs]

What is the fastest way to list all dpIDs on a flashed TuyaMCU device?

Start the TuyaMCU driver, set baud, emulate Wi-Fi state 4, then send tuyaMcu_sendQueryState; the MCU replies with every active dpID in milliseconds [Elektroda, p.kaczmarek2, post #21053452]

Which OpenBeken flags must be enabled to persist the dpID list?

Enable flag 46 (store dpID data) and flag 47 (allow DP command). Without them the DP call returns empty [Elektroda, p.kaczmarek2, post #21053452]

What baud rate should be set for stable TuyaMCU communication?

Most modules ship at 115 200 bps. Use tuyaMcu_setBaudRate 115200; adjust only if logs show garbage characters [Elektroda, p.kaczmarek2, post #21053452]

Why does the DP command sometimes return an empty array?

The list clears after reboot if flags 46/47 aren’t set, or if you haven’t run tuyaMcu_sendQueryState since power-up [Elektroda, p.kaczmarek2, post #21053452]

How many dpIDs can OpenBeken store?

Up to 255 dpIDs, covering the full Tuya spec; exceeding that limit truncates older entries [OpenBeken Docs].

Is cloud connectivity required for dpID extraction?

No. Wi-Fi state 4 merely fools the MCU into believing it’s cloud-connected; the device itself stays local-only [Elektroda, p.kaczmarek2, post #21053452]

How do I interpret dpID types?

Type 1 = boolean, 2 = 32-bit value, 4 = enum; match types when publishing commands to avoid data-length errors [Tuya Protocol v3].

Quick 3-step guide to pull dpIDs for Home Assistant

  1. Flash OpenBeken and add to Wi-Fi.
  2. Run: startDriver TuyaMCU, optional tuyaMcu_setBaudRate 115200, tuyaMCU_defWiFiState 4.
  3. Set flags 46, 47; send tuyaMcu_sendQueryState, then fetch http://<IP>/cm?cmnd=DP for the JSON list [Elektroda, p.kaczmarek2, post #21053452]
Generated by the language model.
ADVERTISEMENT