logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 3018 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 14469 posts with rating 12487, helped 650 times. Been with us since 2014 year.
  • ADVERTISEMENT
📢 Listen (AI):

FAQ

TL;DR: If you flashed a TuyaMCU device with OpenBeken, you can recover a full dpID list with 3 core commands; as the tutorial says, "You don't even need to configure OBK channels." This solves dpID discovery for Home Assistant, MQTT, HTTP apps, and on-device pages by storing queried values, then exposing them as JSON through the DP command. [#21053452]

Why it matters: This method turns a hard-to-read UART state dump into a reusable dpID inventory with types and live values.

Method What you get Format Best use
OpenBeken log Partial or truncated state reply Text log Quick inspection
HTTP cm?cmnd=DP Stored full dpID list JSON Custom apps, REST, local scripts
MQTT Same stored dpID data JSON Home Assistant integration

Key insight: Querying state alone is not enough. Enable flags 46 and 47 first, then rerun tuyaMcu_sendQueryState so OpenBeken stores the returned dpIDs and exposes them through DP.

Quick Facts

  • OpenBeken parses TuyaMCU state packets into dpIDs with an id, type, and data field, then can return them as a JSON array after storage is enabled. [#21053452]
  • The setup shown uses startDriver TuyaMCU, optional tuyaMcu_setBaudRate 115200, and tuyaMCU_defWiFiState 4 before querying state. [#21053452]
  • Example parsed payload sizes are len 1 byte for type 1-bool and type 4-enum, and len 4 bytes for type 2-val integer values. [#21053452]
  • The tutorial stores dpIDs locally in OpenBeken by enabling flags 46 and 47, then reading them through http://192.168.0.206/cm?cmnd=DP or MQTT. [#21053452]

How do I get the full dpID list with types and values from a flashed TuyaMCU device using OpenBeken?

Run the TuyaMCU driver, emulate paired Wi-Fi, query state, then read the stored list. 1. Set up startDriver TuyaMCU and, if needed, tuyaMcu_setBaudRate 115200. 2. Run tuyaMCU_defWiFiState 4, enable flags 46 and 47, and send tuyaMcu_sendQueryState. 3. Read the JSON list through cm?cmnd=DP over HTTP or through MQTT. This returns entries like {"id":128,"type":2,"data":60} with live values. [#21053452]

What is a dpID in TuyaMCU devices, and what do the reported type and data fields mean in OpenBeken?

A dpID is the numbered data point that a TuyaMCU device reports or accepts. "dpID is a device datapoint identifier that labels one function or value, with a fixed data type and payload format." In OpenBeken output, id is that datapoint number, type is the payload class, and data is the current value. The thread shows type 1 as bool, type 2 as val, and type 4 as enum, with examples such as id 103 type 1 data 1 and id 128 type 2 data 60. [#21053452]

What is TuyaMCU in the context of OpenBeken, and how does it communicate with the main WiFi chip?

TuyaMCU is the secondary controller that exchanges state and commands with the main OpenBeken Wi-Fi chip. "TuyaMCU is a UART-connected microcontroller that handles device datapoints, while the Wi-Fi chip queries, parses, and exposes them locally." The thread shows OpenBeken receiving framed serial packets such as 55 AA 03 07 ..., parsing them as state packets, and converting them into dpID entries. That UART link is why driver startup, baud rate, and Wi-Fi-state emulation matter. [#21053452]

Which OpenBeken commands do I need to run before using tuyaMcu_sendQueryState on a TuyaMCU device?

You need to start the driver, set the baud rate if required, and emulate the paired Wi-Fi state. The tutorial shows this sequence in autoexec.bat: startDriver TuyaMCU, optional tuyaMcu_setBaudRate 115200, and tuyaMCU_defWiFiState 4. After that, run tuyaMcu_sendQueryState. If you also want the full list saved for later access, enable flags 46 and 47 before querying. [#21053452]

Why do I need to set tuyaMCU_defWiFiState 4 before querying state from a TuyaMCU device in OpenBeken?

You set tuyaMCU_defWiFiState 4 to emulate a paired, cloud-connected state for the MCU. The tutorial explicitly labels state 0x04 as paired and says to force that state before sending the query. Without that emulation, the TuyaMCU may not return the full state list you want. In practice, this command makes the MCU behave as if Wi-Fi is connected and ready to answer tuyaMcu_sendQueryState. [#21053452]

How can I configure autoexec.bat in OpenBeken so the TuyaMCU driver starts automatically with the right baud rate and WiFi state?

Put the driver and state commands directly in autoexec.bat. The example shown is: startDriver TuyaMCU, optional //tuyaMcu_setBaudRate 115200, and tuyaMCU_defWiFiState 4. Uncomment the baud-rate line if your device needs 115200 baud. After saving that file, rerun autoexec.bat or reboot the device so the configuration loads automatically on startup. [#21053452]

Why is the TuyaMCU reply sometimes truncated in the OpenBeken log, and how can I recover the full dpID list anyway?

The log can truncate a large state reply because the MCU may return many dpIDs in one query. The tutorial warns that the reply "may be truncated in log" and then gives a recovery path. Enable flags 46 and 47, rerun tuyaMcu_sendQueryState, and read the stored results with the DP command instead of relying on the visible log. That method preserves the full list as JSON. [#21053452]

How do flags 46 and 47 work in OpenBeken for TuyaMCU dpID storage, and when should I enable them?

Flags 46 and 47 enable OpenBeken-side storage of TuyaMCU dpIDs. The tutorial says those flags "will enable a TuyaMCU dpID storage on OBK side" and let you run the DP command afterward. Enable them before rerunning tuyaMcu_sendQueryState, not after. That order matters because OpenBeken only stores the returned dpID values once storage is active. [#21053452]

Where can I find the stored TuyaMCU dpIDs in OpenBeken after running tuyaMcu_sendQueryState?

You can find them through the DP command exposed by OpenBeken. The thread shows an HTTP example at http://192.168.0.206/cm?cmnd=DP and states that the same stored results are also available over MQTT. The response is a JSON array of datapoints, each with id, type, and data. That makes the stored list much easier to reuse than scrolling through UART logs. [#21053452]

How do I use the OpenBeken HTTP command cm?cmnd=DP to read TuyaMCU dpIDs in JSON format?

Send an HTTP request to the device with cm?cmnd=DP after you have enabled flags 46 and 47 and rerun the state query. The example URL is http://192.168.0.206/cm?cmnd=DP. OpenBeken returns a JSON array containing objects like id 128, type 2, and data 60. That JSON is suitable for direct parsing in scripts, dashboards, or local tools. [#21053452]

In what way can I access TuyaMCU dpID data through MQTT in OpenBeken for Home Assistant integration?

You can access the same stored dpID list through MQTT as JSON. The tutorial states that the DP output is in JSON format and that you can "also get the same result via MQTT." That means Home Assistant can subscribe to the MQTT payload and read raw datapoints such as id 103 type 1 data 1 or id 110 type 2 data 23993 without requiring channel mapping first. [#21053452]

How can I use raw TuyaMCU dpIDs directly in Home Assistant or a custom app without configuring OpenBeken channels?

Use the stored JSON dpID list directly over MQTT or HTTP instead of mapping every datapoint to an OpenBeken channel. The tutorial says you can process the data in Home Assistant via MQTT, in your own application via HTTP, or even in an HTML page hosted on OpenBeken. It also makes the key point clear: "You don't even need to configure OBK channels." That saves setup time when you only need raw datapoints. [#21053452]

What do OpenBeken log entries like type 1-bool, type 2-val, and type 4-enum mean when parsing TuyaMCU state packets?

They identify the payload type that OpenBeken decoded from each state packet. In the thread, type 1-bool len 1 carries a 1-byte boolean, type 2-val len 4 carries a 4-byte integer, and type 4-enum len 1 carries a 1-byte enumerated value. The log then prints the decoded content, such as byte 0 or int32 401. Those labels help you understand how each dpID should be interpreted. [#21053452]

How does extracting TuyaMCU dpIDs with OpenBeken compare with alternate dpID extraction methods mentioned in the flashing and setup guide?

This OpenBeken method works after flashing and gives you live dpIDs with types and values directly from the device. The post says alternate extraction methods are described in the flashing guide, but this tutorial assumes the device is already flashed and a basic TuyaMCU config works. Its advantage is direct retrieval into JSON through DP, MQTT, or HTTP after one query cycle. That makes it more convenient for integration work than manual log inspection alone. [#21053452]

What are the most common reasons OpenBeken fails to return a complete TuyaMCU dpID list, and how do I troubleshoot baud rate, pairing state, or driver setup issues?

The most common failures are missing driver startup, wrong UART baud rate, missing paired-state emulation, or forgetting flags 46 and 47. Troubleshoot in this order: 1. Confirm startDriver TuyaMCU runs on boot. 2. Set the correct baud, with 115200 shown as the example value. 3. Force tuyaMCU_defWiFiState 4, then rerun tuyaMcu_sendQueryState. If the log still looks incomplete, do not trust the visible dump alone; recover the full list through stored DP JSON instead. [#21053452]
Generated by the language model.
ADVERTISEMENT