logo elektroda
logo elektroda
X
logo elektroda

OpenBeken Support for Tuya 3 Phase Powermeter (ZGMISMART-SPM02)?

vincenzoernst1 4593 45
Best answers

Can OpenBeken display all three phases from a Tuya 3‑phase powermeter, including voltage, current, power, frequency, and forward/reverse energy?

Yes—OpenBeken can handle a 3‑phase Tuya powermeter with separate channels for each phase, and it also supports scriptable TuyaMCU handling plus a custom HTML panel, so you can make it work even if the firmware build does not already have an exact device template [#21091190][#21091338] In the thread, the device was mapped successfully with per-phase frequency, voltages, currents, and powers, and the missing L3 voltage was traced to a dpID typo rather than a firmware limitation [#21094785][#21102601][#21102909] The replies also confirmed that dpID 111 is total power, dpID 1 is total forward energy, and OpenBeken can forward raw values or use custom HASS discovery if a built-in channel type is missing [#21095147][#21095192][#21091338] For derived values like total current, you can script a repeating calculation in autoexec.bat, e.g. sum the phase current channels every second [#21095192][#21095219]
Generated by the language model.
ADVERTISEMENT
  • #31 21102692
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    can you enable verbose logging and give log again? Somehow channel value is lost?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 21102888
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7

    found it in the logs! my fault. typo. sorry!

    next step is to put it to real 3 phase mains. will report back.
  • ADVERTISEMENT
  • #33 21102900
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    What kind of typo was that? Can you show your current autoexec.bat for clarity?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #34 21102909
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7

    I ALWAYS update the config in the opening post!

    I swapped dplds L2 voltage was...err..... 105 ......must happen when I cleared config, cause it worked before
  • #35 21274110
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    @p.kaczmarek2

    im missing the openbeken  build in HA info. it shows "unkown", also the IP doesnt show up in HA. since the info is in mqtt there might be a glitch in the posted topic?

    Diagnostic screen showing Build as unknown in the application.

    Added after 58 [minutes]:

    >>21095146

    @divadiow

    im trying to get the rest of the dpid working. now im searching for reasonable channel types for:

    "DPID 6,7,8: "phase", raw,
    9: "code": "fault", "type": "bitmap",
    "DPID 17,18,19": { "code": "alarm_set_1", "type": "raw",

    any suggestions on what channels to use?

    "DPID 2": { "code": "cur_neutral", "type": "value", this is not reasonablecause this unit has a neutral but its ONLY for self powering the unit. there you only can measure the units power consumption. this is not very usefull.

    16 is "switch" but how?! this is physically simply not possible by design?!?!



    maybe like so?

    //phase_a
    setChannelLabel 14 "L1"
    setChannelType 14 OpenClosed_Inv
    linkTuyaMCUOutputToChannel 6 raw 14
    
    // breaker_id
    setChannelLabel 17 " breaker_id"
    setChannelType 17 ReadOnly
    linkTuyaMCUOutputToChannel 19 string 17
    
    // fault
    setChannelLabel 18 "device fault"
    setChannelType 18 ReadOnly
    linkTuyaMCUOutputToChannel 9 bitmap 18
    


    breaker id shows 0. also its shown as: "Channel breaker_id". channel is not a nice wording here.
    for "OpenClosed_Inv" setChannelLabel 14 "L1" is NOT working. it shows "CLOSED (ch14)". Why?
  • #36 21274799
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Does executing publishAll fix the missing information in MQTT HA (with a delay)?
    Helpful post? Buy me a coffee.
  • #37 21275240
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    @p.kaczmarek2

    with publishAll build is shown correctly. 👍 is this a bug or does it intended behave this way?
    Diagnostic interface displaying software version, signal strength, temperature, and uptime.


    IP doesnt show up though. so the link ("Besuchen" / "visit" in the english version, i guess) to the OB gui does link to the wrong IP:

    Screenshot of a user interface displaying device and sensor information.
  • ADVERTISEMENT
  • #38 21275585
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    I was almost sure that "publishAll" does the same what is done if you enable "broadcast self state on MQTT connect", so it's most likely a bug, but it's very strange... I will need to triple-check it.
    Helpful post? Buy me a coffee.
  • #39 21275591
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    can i help to check?
  • #40 21792941
    Egzi
    Level 14  
    Posts: 145
    Help: 2
    Rate: 13
    Board Language: polish
    I have bought this module lately. Product description says Yagusmart, but on the package it says Zemismart SPM02-D2TW.
    The dpIDs are totally different. Why is that?

    My current autoexec.bat:
    startDriver TuyaMCU
    startDriver httpButtons
    
    // emulate being connected to cloud
    tuyaMCU_defWiFiState 4
    
    setChannelLabel 1 "Energy Forward Total"
    setChannelType 1 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 1 val 1
    
    setChannelLabel 2 "Energy Reverse Total"
    setChannelType 2 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 23 val 2
    
    setChannelLabel 3 "Frequency"
    setChannelType 3 Frequency_div100
    linkTuyaMCUOutputToChannel 32 val 3
    
    setChannelLabel 4 "Current Unbalance"
    setChannelType 4 ReadOnly_div100
    linkTuyaMCUOutputToChannel 130 val 4
    
    setChannelLabel 5 "Power Total"
    setChannelType 5 Power
    linkTuyaMCUOutputToChannel 29 val 5
    
    setChannelLabel 6 "Power Factor"
    setChannelType 6 PowerFactor_div100
    linkTuyaMCUOutputToChannel 50 val 6
    
    setChannelLabel 7 "L1 Voltage"
    setChannelType 7 Voltage_div10
    linkTuyaMCUOutputToChannel 103 val 7
    
    setChannelLabel 8 "L2 Voltage"
    setChannelType 8 Voltage_div10
    linkTuyaMCUOutputToChannel 112 val 8
    
    setChannelLabel 9 "L3 Voltage"
    setChannelType 9 Voltage_div10
    linkTuyaMCUOutputToChannel 121 val 9
    
    setChannelLabel 10 "L1 Current"
    setChannelType 10 Current_div1000
    linkTuyaMCUOutputToChannel 104 val 10
    
    setChannelLabel 11 "L2 Current"
    setChannelType 11 Current_div1000
    linkTuyaMCUOutputToChannel 113 val 11
    
    setChannelLabel 12 "L3 Current"
    setChannelType 12 Current_div1000
    linkTuyaMCUOutputToChannel 122 val 12
    
    setChannelLabel 13 "L1 Power"
    setChannelType 13 Power
    linkTuyaMCUOutputToChannel 105 val 13
    
    setChannelLabel 14 "L2 Power"
    setChannelType 14 Power
    linkTuyaMCUOutputToChannel 114 val 14
    
    setChannelLabel 15 "L3 Power"
    setChannelType 15 Power
    linkTuyaMCUOutputToChannel 123 val 15
    
    setChannelLabel 16 "L1 Power Factor"
    setChannelType 16 PowerFactor_div100
    linkTuyaMCUOutputToChannel 108 val 16
    
    setChannelLabel 17 "L2 Power Factor"
    setChannelType 17 PowerFactor_div100
    linkTuyaMCUOutputToChannel 117 val 17
    
    setChannelLabel 18 "L3 Power Factor"
    setChannelType 18 PowerFactor_div100
    linkTuyaMCUOutputToChannel 126 val 18
    
    setChannelLabel 19 "L1 Energy Forward Total"
    setChannelType 19 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 109 val 19
    
    setChannelLabel 20 "L2 Energy Forward Total"
    setChannelType 20 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 118 val 20
    
    setChannelLabel 21 "L3 Energy Forward Total"
    setChannelType 21 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 127 val 21
    
    setChannelLabel 22 "L1 Energy Reverse Total"
    setChannelType 22 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 110 val 22
    
    setChannelLabel 23 "L2 Energy Reverse Total"
    setChannelType 23 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 119 val 23
    
    setChannelLabel 24 "L3 Energy Reverse Total"
    setChannelType 24 EnergyTotal_kWh_div100
    linkTuyaMCUOutputToChannel 128 val 24
    
    setChannelLabel 25 "Data Report Duration"
    setChannelType 25 TextField
    linkTuyaMCUOutputToChannel 102 val 25
    
    setChannelLabel 26 "Device Locating"
    setChannelType 26 Toggle
    linkTuyaMCUOutputToChannel 101 val 26
    
    setButtonEnabled 1 1
    setButtonLabel 1 "Query State"
    setButtonCommand 1 tuyaMcu_sendQueryState 
    
    setButtonEnabled 2 1
    setButtonLabel 2 "Refresh"
    setButtonCommand 2 "tuyaMcu_sendState 35 enum 0"
    
    setButtonEnabled 3 1
    setButtonLabel 3 "Clear Counters"
    setButtonCommand 3 "tuyaMcu_sendState 12 bool 1"


    There are also some other dpIDs, is there any way to brake down raw or bitmap values into separate channels? Is there a way to display a string dpID?
    6: [0-raw] 0x090A000000000000
    7: [0-raw] 0x090A000000000000
    8: [0-raw] 0x090A000000000000
    9:[5-bitmap] (1000-phaseloss) (0100-overcurrent)
    17: [0-raw]  Raw V=0x7000019 (high power alarm, 0x70uvvvv - u=0 for disabled u=1 for enabled, vvvv-2bytes power value 1-65535kW)
    18: [0-raw] Raw V=01 01 00 3F 02 00 00 0F 03 01 00 FD 04 00 00 B4 05 00 00 00 07 00 00 00
       alarms: 6 values of format - 1-byte setting id, 1-byte enabled=0x01/disabled=0x00, 2-bytes parameter value
          id 01 - overcurrent (1-65535A)
          id 02 - unbalanced load (1-100%)
          id 03 - overvoltage (1-65535V)
          id 04 - undervoltage (1-65535V)
          id 05 - phase loss (no parameter)
          id 07 - negative active power (no parameter)
       
    19: [3-str] "vow25010001" - device id
  • #41 21793000
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    have u made a backup from the orig firmware? if yes, can u post it here?
  • Helpful post
    #42 21793003
    Egzi
    Level 14  
    Posts: 145
    Help: 2
    Rate: 13
    Board Language: polish
    Here is the backup.
    Attachments:
    • readResult_BK7231N_QIO_SPM02_2025-27-12-14-39-26.bin (2 MB) You must be logged in to download this attachment.
  • #43 21818139
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    @divadiow

    would you mind extracting the dpids from the new revision above? thx!
  • #44 21818190
    divadiow
    Level 38  
    Posts: 4839
    Help: 420
    Rate: 852
    Sure. I can't until Sunday evening, tomorrow, however.
  • #45 21818393
    vincenzoernst1
    Level 8  
    Posts: 85
    Help: 3
    Rate: 7
    >>21818190

    no hurrry ;-)
  • Helpful post
    #46 21819489
    divadiow
    Level 38  
    Posts: 4839
    Help: 420
    Rate: 852
    Code: JSON
    Log in, to see the code


    you might have a TuyaMCU update too

    Firmware update screen showing version V1.1.12 found and Auto Upgrade toggle off

Topic summary

✨ The discussion revolves around the compatibility of OpenBeken firmware with the Tuya 3 Phase Powermeter model ZGMISMART-SPM02. The user seeks to determine if OpenBeken can effectively handle and display metrics for three-phase power, voltage, current (both forward and reverse), and frequency, given that Tasmota does not support this functionality. Participants in the forum provide insights on flashing the device with OpenBeken, configuring the TuyaMCU interface, and creating custom HTML panels. They discuss the mapping of data points (dpIDs) for voltage and current readings, troubleshooting issues with displaying all three voltages, and scripting capabilities for data processing. The conversation also touches on the need for proper channel types and the potential for custom scripting to enhance functionality.
Generated by the language model.

FAQ

TL;DR: If you want a Tuya 3-phase meter in OpenBeken, this thread shows 13 mapped channels and confirms that “you can have any possible combination of channel types” on TuyaMCU devices. It solves the exact problem of showing L1/L2/L3 voltage, current, power, total power, frequency, energy, and leakage current on ZGMISMART/Zemismart SPM02-family meters. [#21091338]

Why it matters: This thread documents a working path from BK7231-based Tuya hardware to a usable 3-phase OpenBeken setup, including dpID mapping, troubleshooting, and Home Assistant caveats.

Option 3-phase voltage/current/power handling Thread outcome
OpenBeken + TuyaMCU Multiple mapped channels with labels and dividers Confirmed workable on SPM02-family devices
Tasmota + TuyaMCU Only one voltage, current, and power channel at that time Reported limitation for 3-phase use

Key insight: OpenBeken worked because it treated each TuyaMCU data point as a separate channel, not as a single shared voltage/current/power slot. The main failures in this thread came from dpID typos and mapping mistakes, not from a hard 3-phase limitation. [#21091338]

Quick Facts

  • The working OpenBeken example mapped 13 channels: frequency, 3 voltages, 3 currents, 3 powers, total power, total energy, and leakage current. [#21095139]
  • The first tested unit used a CB2S module with BK7231N, which was described as easier to desolder and swap than CB3S-class modules. [#21092650]
  • One verified live reading showed 234.2 V, 13.78 A, 322 W, and 49.97 Hz on mapped TuyaMCU channels before final refinement. [#21094785]
  • The later hardware revision exposed a much larger map, including per-phase import/export energy, with dpIDs reaching at least 130 and a configurable report interval of 225–3600 seconds. [#21792941]
  • The raw phase packet format described for another revision used 8 bytes per phase: 2 bytes voltage, 3 bytes current, and 3 bytes active power. [#21819489]

How do I configure OpenBeken for a Tuya 3-phase power meter like the ZGMISMART-SPM02 so it shows all three phases of voltage, current, power, total power, frequency, and leakage current?

Map each TuyaMCU dpID to its own OpenBeken channel in autoexec.bat. A working example used frequency on dpID 101, voltages on 102/105/108, currents on 103/106/109, powers on 104/107/110, total power on 111, total energy on 1, and leakage current on 15. Use channel types such as Frequency_div100, Voltage_div10, Current_div100, Power, EnergyTotal_kWh_div1000, and Current_div1000. The thread’s final config exposed 13 useful channels from one SPM02-family meter. [#21095139]

What is a TuyaMCU dpID, and how do I find the correct dpID mappings for a Tuya power meter after flashing OpenBeken?

A TuyaMCU dpID is a device-specific data point identifier that carries one value, such as voltage, current, or a raw packet. After flashing OpenBeken, use raw DP access and inspect the live TuyaMCU log while applying known loads. In this thread, the user identified phase channels by wiring one test phase so current doubled across L1, L2, and L3, then matched the lowest and highest readings to each phase. That method made dpID identification practical before final mapping. [#21092438]

Why can OpenBeken handle multiple voltage, current, and power channels on a TuyaMCU device while Tasmota struggles with 3-phase power meters?

OpenBeken can map many TuyaMCU outputs to separate channels, while Tasmota was reported here as allowing only one voltage, one current, and one power channel at that time. The thread states that OpenBeken has “any possible combination of channel types” for this use, and it can also ignore fixed dpID mapping types and forward raw values instead. That difference is why the same 3-phase meter was considered workable in OpenBeken but blocked in Tasmota. [#21091338]

What is autoexec.bat in OpenBeken, and how do I use it to map TuyaMCU outputs to channels with the right dividers and labels?

autoexec.bat is OpenBeken’s startup script that defines drivers, channel labels, channel types, and dpID links. In this thread, the pattern was simple: startDriver TuyaMCU, then setChannelLabel, setChannelType, and linkTuyaMCUOutputToChannel <dpid> val <channel>. For example, voltage used Voltage_div10, frequency used Frequency_div100, and energy used EnergyTotal_kWh_div1000. That gives you readable names such as “L1 Voltage” and correct scaling from raw TuyaMCU values. [#21090978]

What's the step-by-step process to back up the original BK7231 firmware, flash OpenBeken, and start testing a CB2S-based Tuya power meter safely?

Use a three-step process. 1. Make a full 2 MB backup of the original BK7231 flash before any change. 2. Flash OpenBeken and confirm the module type; this unit used CB2S / BK7231N. 3. Start with one known phase and inspect live dpIDs before moving to full 3-phase mains. The thread also recommends photos, a dpID list, and live logs early in the process. That sequence reduced risk and preserved a recovery path. [#21091295]

How can I troubleshoot missing or incorrect L1, L2, or L3 voltage readings in OpenBeken when the TuyaMCU logs show the dpID values correctly?

Check the mapping first, because a displayed voltage can disappear even when the dpID value is present in logs. In this thread, the logs clearly showed dpID 108 reporting 233.2–233.3 V, but the UI still missed a phase because the user had swapped voltage dpIDs by mistake. The final root cause was a typo in autoexec.bat, not a TuyaMCU failure. Save config, reboot, and re-read every linkTuyaMCUOutputToChannel line when one phase vanishes. [#21102909]

Which OpenBeken channel types should I use for 3-phase meter values like Voltage_div10, Current_div100 or div1000, Frequency_div100, Power, and EnergyTotal?

Use the divider that matches the meter’s actual dpID scale. In this thread, one SPM02 mapping used Voltage_div10, Current_div100, Frequency_div100, Power, EnergyTotal_kWh_div1000, and Current_div1000 for leakage current. A later revision used Current_div1000, PowerFactor_div100, and EnergyTotal_kWh_div100 for several values. The right answer depends on the specific hardware revision and its dpID scales, not just the product family name. [#21792941]

How do I use tuyaMcu_sendQueryState and verbose logging in OpenBeken to discover all data points from a TuyaMCU-based electricity meter?

Run tuyaMcu_sendQueryState and enable verbose logging, then watch the TuyaMCU parser report each dpID, type, and value. The thread explicitly recommends tuyaMcu_sendQueryState for querying all data points from the MCU on demand. That helps when a meter only pushes some values periodically or when you need to confirm whether a missing UI value is a mapping issue or a reporting issue. It is the fastest way to inventory dpIDs after flashing. [#21095113]

What do dpIDs 1, 2, 6, 7, 8, 9, 17, 18, 19, and 111 mean on the ZGMISMART or Zemismart SPM02 family of 3-phase meters?

On the original mapping discussed here, dpID 1 was total forward energy, 2 was neutral current, 6/7/8 were raw phase packets, 9 was a fault bitmap, 17 and 18 were alarm-setting raw values, 19 was breaker or device ID, and 111 was total active power. The thread later verified 111 by changing load and seeing it drop instantly to 0 when the load was removed. Those meanings fit one SPM02-family revision, not every revision sold under similar branding. [#21095146]

How can I create calculated channels in OpenBeken, such as total current or derived values, using autoexec.bat loops or repeating events?

Create an extra channel and update it from existing channels with a repeating script. The thread gives a concrete example for total current: setChannel 10 $CH11+$CH12+$CH13, with the note that you should run it every 1 second using a loop or repeating event. The same approach works for derived totals or synthetic sensors that the meter never reports directly. You do not need a native dpID for every displayed value. [#21095192]

Why does Home Assistant show the OpenBeken build as 'unknown' or miss the device IP until publishAll is run, and how can that MQTT discovery issue be fixed?

The thread points to an MQTT discovery bug or incomplete state broadcast. In the reported case, Home Assistant showed the OpenBeken build as “unknown” until publishAll was executed, and the build then appeared correctly. The device IP still did not show afterward, so the “Visit” link kept using the wrong address. The maintainer suspected publishAll should match the normal “broadcast self state on MQTT connect” behavior, which suggests a bug rather than intended behavior. [#21275585]

How should I display raw, bitmap, and string TuyaMCU dpIDs in OpenBeken for values like phase_a/phase_b/phase_c, fault alarms, and breaker_id?

Map string dpIDs directly, use read-only channels for opaque values, and expect some UI labels to be generic. In this thread, the user linked breaker_id from dpID 19 as a string and a fault value from dpID 9 as a bitmap. A raw phase value was also tested with OpenClosed_Inv, but the UI showed CLOSED (ch14) instead of the custom label, which made it unsuitable for meaningful phase display. That is a display limitation, not proof the dpID is wrong. [#21274110]

What is the difference between CB2S, CB3S, and BK7231N modules when modding Tuya devices, and why was CB2S considered easier to swap here?

In this thread, CB2S was the favorable module because it used BK7231N and was physically easier to desolder and swap than CB3S-class boards. The maintainer explicitly said CB2S, TYWE2S, and WB2S are easier to replace than CB3S or TYWE3S. That mattered because the project involved removing the stock Wi-Fi module and fitting a flashed OpenBeken-compatible one. The hardware convenience, not a feature difference in metering, drove that preference. [#21092650]

How do different hardware revisions of the Zemismart or Yagusmart SPM02 end up with completely different dpID maps, and how can I identify the right mapping for my unit?

Different revisions can ship with different TuyaMCU firmware and product definitions, so the same SPM02-family label does not guarantee the same dpID map. A later buyer reported a unit sold as Yagusmart or Zemismart SPM02-D2TW with a “totally different” map, including total reverse energy on dpID 23, frequency on 32, and per-phase voltage starting at 103, 112, and 121. Identify your unit by backing up original firmware, querying all dpIDs, and testing each value under controlled loads. [#21792941]

What is the best way to decode Tuya raw phase packets and bitmap alarm fields from a 3-phase meter into separate OpenBeken channels or Home Assistant entities?

Decode them from the vendor’s packet definition, then split them before publishing. “TuyaMCU is a serial protocol bridge that exchanges typed dpIDs between the Wi-Fi module and the metering MCU, including value, raw, bitmap, and string payloads.” In the later revision, each raw phase packet used 8 bytes: 2 bytes voltage, 3 bytes current, and 3 bytes active power, all big-endian. The fault bitmap defined up to 17 labels, including overload, undervoltage, and phase-loss alarms. That makes raw-to-entity parsing feasible, but it needs custom handling outside simple one-line channel links. [#21819489]
Generated by the language model.
ADVERTISEMENT