logo elektroda
logo elektroda
X
logo elektroda

[CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

vincenzoernst1 408 9
ADVERTISEMENT
  • #1 21905281
    vincenzoernst1
    Level 9  
    Posts: 96
    Help: 3
    Rate: 7
    OpenBeken Support for Tuya 3 Phase Powermeter (ZGMISMART-SPM02)

    thx to divadiow, John_SolderWick and Egzi for the infos!


    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"



    raw id´s:
    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



    json out:

    {
      "result": {
        "model": {
          "modelId": "g5n4t0",
          "services": [
            {
              "actions": [],
              "code": "",
              "description": "",
              "events": [],
              "name": "默认服务 (Default service)",
              "properties": [
                {
                  "abilityId": 1,
                  "accessMode": "ro",
                  "code": "forward_energy_total",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1152"
                  },
                  "name": "累计正向有功电能 (Cumulative forward active energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 6,
                  "accessMode": "ro",
                  "code": "phase_a",
                  "description": "1,A相电压,电流及功率 (Phase A voltage, current and power)\\n2,大端模式,HEX格式,共8个字节 (Big-endian, HEX format, total 8 bytes)\\n3,单位精度:电压,2字节,单位0.1V。电流,3字节,单位 0.001A 。A相有功功率,3字节,单位0.0001kW (Unit precision: Voltage 2 bytes, 0.1V; Current 3 bytes, 0.001A; Phase A active power 3 bytes, 0.0001kW)\\n4,报文格式 (Message format)\\n举例:08 80 00 03 E8 00 27 10 表示A相217.6V,A相电流1.000A,A相功率10.000KW (Example: 08 80 00 03 E8 00 27 10 means Phase A 217.6V, Phase A current 1.000A, Phase A power 10.000KW)\\n5,通信逻辑: (Communication logic:)\\n1)用户进面板,主动查询。用户进入面板,面板马上下发0x08到电表,电表上报数据到云平台,面板拿到数据,然后展示。 注:最新WIFI支持。    (1) User enters the panel and actively queries. When user enters the panel, panel immediately sends 0x08 to the meter, meter reports data to the cloud, panel receives data and displays it. Note: supported by latest WiFi.)\\n2)电表基于一定周期上报数据。建议:在WIFI模式时,15秒上报一次。NB模式时,1个小时上报一次。 (2) Meter reports data periodically. Suggestion: in WiFi mode, report every 15 seconds; in NB mode, report every 1 hour.)",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1152"
                  },
                  "name": "X相电压,电流及功率 (X-phase voltage, current and power)",
                  "typeSpec": {
                    "type": "raw",
                    "maxlen": 128
                  }
                },
                {
                  "abilityId": 7,
                  "accessMode": "ro",
                  "code": "phase_b",
                  "description": "1,B相电压,电流及功率 (Phase B voltage, current and power)\\n2,大端模式,HEX格式,共8个字节 (Big-endian, HEX format, total 8 bytes)\\n3,单位精度:电压,2字节,单位0.1V。电流,3字节,单位 0.001A 。B相有功功率,3字节,单位0.0001kW (Unit precision: Voltage 2 bytes, 0.1V; Current 3 bytes, 0.001A; Phase B active power 3 bytes, 0.0001kW)\\n4,报文格式 (Message format)\\n举例:08 80 00 03 E8 00 27 10 表示B相217.6V,B相电流1.000A,B相功率10.000KW (Example: 08 80 00 03 E8 00 27 10 means Phase B 217.6V, Phase B current 1.000A, Phase B power 10.000KW)\\n5,通信逻辑: (Communication logic:)\\n1)用户进面板,主动查询。用户进入面板,面板马上下发0x00到电表,电表上报数据到云平台,面板拿到数据,然后展示。     (1) User enters the panel and actively queries. When user enters the panel, panel immediately sends 0x00 to the meter, meter reports data to the cloud, panel receives data and displays it.)\\n2)电表基于一定周期上报数据。建议:在WIFI模式时,15秒上报一次。NB模式时,1个小时上报一次。 (2) Meter reports data periodically. Suggestion: in WiFi mode, report every 15 seconds; in NB mode, report every 1 hour.)",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1152"
                  },
                  "name": "Y相电压,电流及功率 (Y-phase voltage, current and power)",
                  "typeSpec": {
                    "type": "raw",
                    "maxlen": 128
                  }
                },
                {
                  "abilityId": 8,
                  "accessMode": "ro",
                  "code": "phase_c",
                  "description": "1,C相电压,电流及功率 (Phase C voltage, current and power)\\n2,大端模式,HEX格式,共8个字节 (Big-endian, HEX format, total 8 bytes)\\n3,单位精度:电压,2字节,单位0.1V。电流,3字节,单位 0.001A 。C相有功功率,3字节,单位0.0001kW (Unit precision: Voltage 2 bytes, 0.1V; Current 3 bytes, 0.001A; Phase C active power 3 bytes, 0.0001kW)\\n4,报文格式 (Message format)\\n举例:08 80 00 03 E8 00 27 10 表示C相217.6V,C相电流1.000A,C相功率10.000KW (Example: 08 80 00 03 E8 00 27 10 means Phase C 217.6V, Phase C current 1.000A, Phase C power 10.000KW)\\n5,通信逻辑: (Communication logic:)\\n1)用户进面板,主动查询。用户进入面板,面板马上下发0x08到电表,电表上报数据到云平台,面板拿到数据,然后展示。     (1) User enters the panel and actively queries. When user enters the panel, panel immediately sends 0x08 to the meter, meter reports data to the cloud, panel receives data and displays it.)\\n2)电表基于一定周期上报数据。建议:在WIFI模式时,15秒上报一次。NB模式时,1个小时上报一次。 (2) Meter reports data periodically. Suggestion: in WiFi mode, report every 15 seconds; in NB mode, report every 1 hour.)",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1152"
                  },
                  "name": "Z相电压,电流及功率 (Z-phase voltage, current and power)",
                  "typeSpec": {
                    "type": "raw",
                    "maxlen": 128
                  }
                },
                {
                  "abilityId": 9,
                  "accessMode": "ro",
                  "code": "fault",
                  "description": "1,告警 (Alarm)\\n2,大端模式,HEX,4字节 (Big-endian, HEX, 4 bytes)\\n3,报文格式 (Message format)\\n按照完整4个字节,对应的告警位上报告警;bit位,1表示有告警,0表示无告警;如果没用的告警位,补0。高位无定义,也补0; (Use full 4 bytes; report alarm bits accordingly: bit=1 means alarm present, bit=0 means no alarm. Unused alarm bits fill with 0. High bits undefined also fill with 0.)\\n举例:0X00 00 00 09,表示当前发生了漏电自检不正常告警和短路告警,无其它告警。 (Example: 0x00 00 00 09 means leakage self-test abnormal alarm and short circuit alarm occurred, no other alarms.)\\n4,通信逻辑 (Communication logic)\\n只要有1个告警发生,就完整4个字节上报给面板;只要有1个告警关闭,就完整4个字节上报给面板,更新面板显示。 (If any alarm occurs, report full 4 bytes to panel; if any alarm clears, report full 4 bytes to panel to update display.)",
                  "extensions": {
                    "iconName": "icon-baojing",
                    "scope": "fault",
                    "attribute": "1664"
                  },
                  "name": "故障告警 (Fault alarm)",
                  "typeSpec": {
                    "type": "bitmap",
                    "label": [
                      "short_circuit_alarm",
                      "surge_alarm",
                      "overload_alarm",
                      "leakagecurr_alarm",
                      "temp_dif_fault",
                      "fire_alarm",
                      "high_power_alarm",
                      "self_test_alarm",
                      "ov_cr",
                      "unbalance_alarm",
                      "ov_vol",
                      "undervoltage_alarm",
                      "miss_phase_alarm",
                      "outage_alarm",
                      "magnetism_alarm",
                      "credit_alarm",
                      "no_balance_alarm"
                    ],
                    "maxlen": 17
                  }
                },
                {
                  "abilityId": 12,
                  "accessMode": "rw",
                  "code": "clear_energy",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1024"
                  },
                  "name": "电能清零 (Reset energy)",
                  "typeSpec": {
                    "type": "bool"
                  }
                },
                {
                  "abilityId": 17,
                  "accessMode": "rw",
                  "code": "alarm_set_1",
                  "description": "1,告警阈值使能控制及设置1 (Alarm threshold enable control & setting 1)\\n2,HEX格式,大端模式, 总告警的数量*4字节= 设置告警总长度。 (HEX format, big-endian; total alarms * 4 bytes = total setting length)\\n3,报文格式 (Message format)\\n每个告警由4个字节组成,第1个字节(表示该告警存在);第2个字节(发生此告警时,断路器控制模式(0X01拉闸,0X00不动作只告警);第3、4字节:设置告警阈值。 (Each alarm uses 4 bytes: byte1 indicates alarm exists; byte2 is breaker control mode on alarm (0x01 trip, 0x00 no action only alarm); bytes3-4 set threshold.)\\n举例:0X01 01 00 00 03 01 00 14,表示该断路器支持短路告警,发生该告警时,自动跳闸,阀值补0。支持过载告警,发生该告警时,拉闸动作,动作阀值20KW。无其它告警功能。注:没有的告警,就不要上报字节。 (Example: 0x01 01 00 00 03 01 00 14 means short circuit alarm supported and trips (threshold 0), overload alarm supported and trips at 20kW. No other alarms. Note: do not report bytes for unsupported alarms.)\\n4,通信逻辑 (Communication logic)\\nA,配网成功后,按照上面的格式,主动上报给云平台,面板知道哪些告警是断路器当前支持的。设置不成功,重新配网再上报。 (A: After pairing, report supported alarms to cloud; if setup fails, re-pair and report again.)\\nB,断路器上电时,也上报一次。 (B: Report once on power-up.)\\nC,面板根据协议下发告警设置。 (C: Panel sends alarm settings according to protocol.)\\n5 APP面板支持第一字节能力清单:01短路告警,02浪涌告警,03过载告警,04漏电告警,05高温告警,06打火告警,07功率过高告警,08漏电自检异常告警 (APP panel byte1 capability list: 01 short circuit, 02 surge, 03 overload, 04 leakage, 05 high temp, 06 arcing, 07 high power, 08 leakage self-test abnormal)",
                  "extensions": {
                    "iconName": "icon-dp_warming",
                    "attribute": "1024"
                  },
                  "name": "告警设置1 (Alarm settings 1)",
                  "typeSpec": {
                    "type": "raw",
                    "maxlen": 128
                  }
                },
                {
                  "abilityId": 18,
                  "accessMode": "rw",
                  "code": "alarm_set_2",
                  "description": "1,告警阈值使能控制及设置2   (Alarm threshold enable control & setting 2)\\n2,HEX格式,大端模式 (HEX format, big-endian)\\n3,报文格式 (Message format)\\n每个告警由4个字节组成,第1个字节(表示该告警存在);第2个字节(发生此告警时,断路器控制模式(0X01拉闸,0X00不动作只告警);第3、4字节:设置告警阈值 (Each alarm uses 4 bytes: byte1 indicates alarm exists; byte2 is breaker control mode (0x01 trip, 0x00 no action only alarm); bytes3-4 set threshold)\\n举例:0X01 01 00 3C 03 01 00 F5,表示该断路器支持过流告警,发生该告警时,拉闸动作,动作阀值60A。支持过压告警,发生该告警时,拉闸动作,动作阀值245V (Example: 0x01 01 00 3C 03 01 00 F5 means over-current alarm supported and trips at 60A; over-voltage alarm supported and trips at 245V)\\n4,通信逻辑 (Communication logic)\\nA,配网成功后,按照上面的格式,主动上报给云平台,面板知道哪些告警是断路器当前支持的。设置不成功,重新配网再上报。 (A: After pairing, report supported alarms to cloud; if setup fails, re-pair and report again.)\\nB,断路器上电时,也上报一次。 (B: Report once on power-up.)\\nC,面板根据协议下发告警设置。 (C: Panel sends alarm settings according to protocol.)",
                  "extensions": {
                    "iconName": "icon-dp_warming",
                    "attribute": "1152"
                  },
                  "name": "告警设置2 (Alarm settings 2)",
                  "typeSpec": {
                    "type": "raw",
                    "maxlen": 128
                  }
                },
                {
                  "abilityId": 19,
                  "accessMode": "ro",
                  "code": "breaker_id",
                  "description": "1,设备号 (Device ID)\\n2,大端模式,字符串型 (Big-endian, string type)\\n3,单位精度 (Unit precision)\\n4,报文格式 (Message format)\\n5,通信逻辑 (Communication logic)\\nA,配网时上报三次,以确保上报成功。如果配对成功,面板有显示设备号。 (A: Report 3 times during pairing to ensure success; if paired successfully, panel shows device ID.)\\nB,如果配对成功,面板没有显示设备号,需要移除设备,再配置一遍。 (B: If paired but panel does not show device ID, remove device and configure again.)\\nC,每次断路器上电,也上报一次。 (C: Report once each time breaker powers on.)",
                  "extensions": {
                    "iconName": "icon-dp_mode",
                    "attribute": "1152"
                  },
                  "name": "设备号显示 (Device ID display)",
                  "typeSpec": {
                    "type": "string",
                    "maxlen": 255
                  }
                },
                {
                  "abilityId": 23,
                  "accessMode": "ro",
                  "code": "reverse_energy_total",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1024"
                  },
                  "name": "累计反向有功电能 (Cumulative reverse active energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 29,
                  "accessMode": "rw",
                  "code": "active_power",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dianliang",
                    "attribute": "1152"
                  },
                  "name": "总有功功率 (Total active power)",
                  "typeSpec": {
                    "type": "value",
                    "max": 200000,
                    "min": -200000,
                    "scale": 3,
                    "step": 1,
                    "unit": "kW"
                  }
                },
                {
                  "abilityId": 32,
                  "accessMode": "ro",
                  "code": "supply_frequency",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dp_lightning",
                    "attribute": "1152"
                  },
                  "name": "频率 (Frequency)",
                  "typeSpec": {
                    "type": "value",
                    "max": 9999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "Hz"
                  }
                },
                {
                  "abilityId": 35,
                  "accessMode": "rw",
                  "code": "online_state",
                  "description": "可用于APP交互更新机制,例如进入面板点击刷新按钮会下发online,设备感知后立即上报一次最新的例如电流电压功率等希望及时更新展示的数据dp。 (Can be used for APP interactive update mechanism; for example entering the panel and pressing refresh sends 'online'; device then immediately reports the latest data DPs such as current/voltage/power for timely update and display.)",
                  "extensions": {
                    "iconName": "icon-dp_updown"
                  },
                  "name": "面板在线 (Panel online)",
                  "typeSpec": {
                    "type": "enum",
                    "range": [
                      "online",
                      "offline"
                    ]
                  }
                },
                {
                  "abilityId": 50,
                  "accessMode": "rw",
                  "code": "power_factor",
                  "description": "",
                  "extensions": {
                    "iconName": "icon-dp_lightning"
                  },
                  "name": "总功率因数 (Total power factor)",
                  "typeSpec": {
                    "type": "value",
                    "max": 100,
                    "min": -100,
                    "scale": 2,
                    "step": 1,
                    "unit": ""
                  }
                },
                {
                  "abilityId": 101,
                  "accessMode": "rw",
                  "code": "device_locating",
                  "description": "开启后LED绿灯闪烁一定时间后恢复 (After enabling, the green LED blinks for a period of time then restores)",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "设备定位 (Device locating)",
                  "typeSpec": {
                    "type": "bool"
                  }
                },
                {
                  "abilityId": 102,
                  "accessMode": "rw",
                  "code": "data_report_duration",
                  "description": "数据多久上报一次 (How often data is reported)",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "数据上报间隔时间 (Data report interval time)",
                  "typeSpec": {
                    "type": "value",
                    "max": 3600,
                    "min": 225,
                    "scale": 0,
                    "step": 1,
                    "unit": "seconds"
                  }
                },
                {
                  "abilityId": 103,
                  "accessMode": "ro",
                  "code": "cur_voltage_x",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相电压 (X-phase voltage)",
                  "typeSpec": {
                    "type": "value",
                    "max": 5000,
                    "min": 0,
                    "scale": 1,
                    "step": 1,
                    "unit": "V"
                  }
                },
                {
                  "abilityId": 104,
                  "accessMode": "ro",
                  "code": "cur_current_x",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相电流 (X-phase current)",
                  "typeSpec": {
                    "type": "value",
                    "max": 1000000,
                    "min": -1000000,
                    "scale": 3,
                    "step": 1,
                    "unit": "A"
                  }
                },
                {
                  "abilityId": 105,
                  "accessMode": "ro",
                  "code": "cur_power_x",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相有功功率 (X-phase active power)",
                  "typeSpec": {
                    "type": "value",
                    "max": 200000,
                    "min": -200000,
                    "scale": 3,
                    "step": 1,
                    "unit": "kW"
                  }
                },
                {
                  "abilityId": 108,
                  "accessMode": "ro",
                  "code": "power_factor_x",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相功率因数 (X-phase power factor)",
                  "typeSpec": {
                    "type": "value",
                    "max": 100,
                    "min": -100,
                    "scale": 2,
                    "step": 1,
                    "unit": ""
                  }
                },
                {
                  "abilityId": 109,
                  "accessMode": "ro",
                  "code": "x_total_import_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相正向电能 (X-phase forward energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 110,
                  "accessMode": "ro",
                  "code": "x_total_export_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "X相反向电能 (X-phase reverse energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 112,
                  "accessMode": "ro",
                  "code": "cur_voltage_y",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相电压 (Y-phase voltage)",
                  "typeSpec": {
                    "type": "value",
                    "max": 5000,
                    "min": 0,
                    "scale": 1,
                    "step": 1,
                    "unit": "V"
                  }
                },
                {
                  "abilityId": 113,
                  "accessMode": "ro",
                  "code": "cur_current_y",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相电流 (Y-phase current)",
                  "typeSpec": {
                    "type": "value",
                    "max": 1000000,
                    "min": -1000000,
                    "scale": 3,
                    "step": 1,
                    "unit": "A"
                  }
                },
                {
                  "abilityId": 114,
                  "accessMode": "ro",
                  "code": "cur_power_y",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相有功功率 (Y-phase active power)",
                  "typeSpec": {
                    "type": "value",
                    "max": 200000,
                    "min": -200000,
                    "scale": 3,
                    "step": 1,
                    "unit": "kW"
                  }
                },
                {
                  "abilityId": 117,
                  "accessMode": "ro",
                  "code": "power_factor_y",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相功率因数 (Y-phase power factor)",
                  "typeSpec": {
                    "type": "value",
                    "max": 100,
                    "min": -100,
                    "scale": 2,
                    "step": 1,
                    "unit": ""
                  }
                },
                {
                  "abilityId": 118,
                  "accessMode": "ro",
                  "code": "y_total_import_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相正向电能 (Y-phase forward energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 119,
                  "accessMode": "ro",
                  "code": "y_total_export_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Y相反向电能 (Y-phase reverse energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 121,
                  "accessMode": "ro",
                  "code": "cur_voltage_z",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相电压 (Z-phase voltage)",
                  "typeSpec": {
                    "type": "value",
                    "max": 5000,
                    "min": 0,
                    "scale": 1,
                    "step": 1,
                    "unit": "V"
                  }
                },
                {
                  "abilityId": 122,
                  "accessMode": "ro",
                  "code": "cur_current_z",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相电流 (Z-phase current)",
                  "typeSpec": {
                    "type": "value",
                    "max": 1000000,
                    "min": -1000000,
                    "scale": 3,
                    "step": 1,
                    "unit": "A"
                  }
                },
                {
                  "abilityId": 123,
                  "accessMode": "ro",
                  "code": "cur_power_z",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相有功功率 (Z-phase active power)",
                  "typeSpec": {
                    "type": "value",
                    "max": 200000,
                    "min": -200000,
                    "scale": 3,
                    "step": 1,
                    "unit": "kW"
                  }
                },
                {
                  "abilityId": 126,
                  "accessMode": "ro",
                  "code": "power_factor_z",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相功率因数 (Z-phase power factor)",
                  "typeSpec": {
                    "type": "value",
                    "max": 100,
                    "min": -100,
                    "scale": 2,
                    "step": 1,
                    "unit": ""
                  }
                },
                {
                  "abilityId": 127,
                  "accessMode": "ro",
                  "code": "z_total_import_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相正向电能 (Z-phase forward energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 128,
                  "accessMode": "ro",
                  "code": "z_total_export_energy",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "Z相反向电能 (Z-phase reverse energy)",
                  "typeSpec": {
                    "type": "value",
                    "max": 999999999,
                    "min": 0,
                    "scale": 2,
                    "step": 1,
                    "unit": "kW.h"
                  }
                },
                {
                  "abilityId": 130,
                  "accessMode": "ro",
                  "code": "current_unbalance",
                  "description": "",
                  "extensions": {
                    "scope": ""
                  },
                  "name": "三相电流不平衡度 (Three-phase current unbalance degree)",
                  "typeSpec": {
                    "type": "value",
                    "max": 1000,
                    "min": 0,
                    "scale": 0,
                    "step": 1,
                    "unit": "%"
                  }
                }
              ]
            }
          ]
        }
      },
      "success": true,
      "t": 1769361910024,
      "tid": "ccafff18fa1211f0b748aa353f4c03b2"
    }
    
    Attachments:
    • BK7231N_QIO_SPM02_2025-27-12-backup.bin (2 MB) You must be logged in to download this attachment.
    • BK7231N_QIO_SPM02-D2TW_2026-17-5-backup.bin (2 MB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #2 21905289
    vincenzoernst1
    Level 9  
    Posts: 96
    Help: 3
    Rate: 7
    @John_SolderWick

    just flash the CB2S and add the autoexec.bat from Egzi from above to the unit and we will see if it works.
  • #3 21905812
    John_SolderWick
    Level 5  
    Posts: 6
    Help: 1
    Rate: 1
    Thank you @vincenzoernst1, I didn't realize the other thread was for the v1 version, or did you update/split the threads when you realized they were not the same?

    I don't have 3-phase power here in my apartment. I created a similar 1 phase test-setup as the one you showed in the other thread, but I instead adding +1x the current per phase, like 1, 2, 3x I went for doubling it for each step. so 1, 2, 4x the power.

    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter


    With the autoexec.bat config from above these are my results. Not sure if the device support a 1-phase setup like this, or if it requires a 3-phase connection with phasors close to expected of such a system.

    First of all, thank you for helping me with this, I've never managed an OpenBeken device before, so bare with me. The most basic things like finding my way to the web application to set up the autoexec.bat took me embarrassingly long to figure out. XD

    After a restart these are the values displayed:

    EnergyTotal 1.710kWh (Energy Forward Total)
    EnergyTotal 0.000kWh (Energy Reverse Total)
    Frequency 49.970Hz (Frequency)
    ReadOnly: 0.000 (Current Unbalance)
    Power 92.0W (Power Total)
    PowerFactor 0.579 (Power Factor)
    Voltage 9.80V (L1 Voltage)
    Voltage 0.00V (L2 Voltage)
    Voltage 0.00V (L3 Voltage)
    Current 0.0130A (L1 Current)
    Current 0.0000A (L2 Current)
    Current 0.0000A (L3 Current)
    Power 2312.0W (L1 Power)
    Power 0.0W (L2 Power)
    Power 0.0W (L3 Power)
    PowerFactor 23.149 (L1 Power Factor)
    PowerFactor 0.000 (L2 Power Factor)
    PowerFactor 0.000 (L3 Power Factor)
    EnergyTotal 4.030kWh (L1 Energy Forward Total)
    EnergyTotal 0.000kWh (L2 Energy Forward Total)
    EnergyTotal 0.000kWh (L3 Energy Forward Total)
    EnergyTotal 0.529kWh (L1 Energy Reverse Total)
    EnergyTotal 0.000kWh (L2 Energy Reverse Total)
    EnergyTotal 0.000kWh (L3 Energy Reverse Total)

    And here's the log output for when the values update, I don't know if this is the relevant data to figure out if somethings wrong, nor if there's a better way to export it.

    Info:MAIN:Time 781, idle 163404/s, free 63920, MQTT 0(48), bWifi 1, secondsWithNoPing 710, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 03 00 00 01 01 04 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 0 (Hearbeat) len 8
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 782, idle 172036/s, free 64136, MQTT 0(49), bWifi 1, secondsWithNoPing 711, socks 2/38 
    U:ProcessIncoming[v=3]: cmd 7 (State) len 19
    Info:TuyaMCU:ParseState: id 6 type 0-raw len 8
    Info:TuyaMCU:Received: 55 AA 03 07 00 0C 07 00 00 08 09 0C 00 00 D1 00 00 1B 25 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 19
    Info:TuyaMCU:ParseState: id 7 type 0-raw len 8
    Info:TuyaMCU:Received: 55 AA 03 07 00 0C 08 00 00 08 09 0E 00 01 97 00 00 36 0A 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 19
    Info:TuyaMCU:ParseState: id 8 type 0-raw len 8
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 20 02 00 04 00 00 13 8A D4 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 32 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 5002
    Info:GEN:No change in channel 3 (still set to 5002) - ignoring
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 1D 02 00 04 00 00 00 5C 90 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 29 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 92
    Info:GEN:No change in channel 5 (still set to 92) - ignoring
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 32 02 00 04 00 00 00 3B 84 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 50 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 59
    Info:GEN:No change in channel 6 (still set to 59) - ignoring
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 09 05 00 01 00 1D 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 9 type 5-bitmap len 1
    Info:TuyaMCU:ParseState: byte 0
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 66 02 00 04 00 00 09 0D 93 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 102 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 2317
    Info:GEN:CHANNEL_Set channel 25 has changed to 2317 (flags 0)
    Info:MQTT:Channel has changed! Publishing 2317 to channel 25
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 67 02 00 04 00 00 00 62 E0 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 103 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 98
    Info:GEN:No change in channel 7 (still set to 98) - ignoring
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 68 02 00 04 00 00 00 0D 8C 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 104 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 13
    Info:GEN:No change in channel 10 (still set to 13) - ignoring
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 69 02 00 04 00 00 09 0C 95 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 105 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 2316
    Info:GEN:CHANNEL_Set channel 13 has changed to 2316 (flags 0)
    Info:MQTT:Channel has changed! Publishing 2316 to channel 13
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6A 02 00 04 00 00 00 D1 52 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 106 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 209
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6B 02 00 04 00 00 00 1B 9D 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 107 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 27
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6C 02 00 04 00 00 09 0E 9A 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 108 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 2318
    Info:GEN:CHANNEL_Set channel 16 has changed to 2318 (flags 0)
    Info:MQTT:Channel has changed! Publishing 2318 to channel 16
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6D 02 00 04 00 00 01 97 1C 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 109 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 407
    Info:GEN:CHANNEL_Set channel 19 has changed to 407 (flags 0)
    Info:MQTT:Channel has changed! Publishing 407 to channel 19
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 6E 02 00 04 00 00 00 36 BB 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 110 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 54
    Info:GEN:No change in channel 22 (still set to 54) - ignoring
    Info:MAIN:Time 783, idle 101918/s, free 64136, MQTT 0(49), bWifi 1, secondsWithNoPing 712, socks 2/38 
    Info:MAIN:Time 784, idle 173585/s, free 64136, MQTT 0(49), bWifi 1, secondsWithNoPing 713, socks 2/38 


    @divadiow
    There's a second chip on it, I've already tried to see what it is, but it's covered by a second PCB and I were unable to read anything off it, at least with my bad eyes.

    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

    I just got it all put together again after flashing. If we can get this one working I plan to flash my second unit as well, and could de-solder the extra PCB to check the IC when I have that one apart.
  • ADVERTISEMENT
  • #4 21905901
    vincenzoernst1
    Level 9  
    Posts: 96
    Help: 3
    Rate: 7
    what load have u attached to it?

    imho it would be much easier to loop every phase the same. so every phase must show the same for now. the you see if is working right.

    you need to compare the id´ s from the json to the autoexec.bat if they match
  • ADVERTISEMENT
  • #5 21906073
    John_SolderWick
    Level 5  
    Posts: 6
    Help: 1
    Rate: 1
    I've through trial and error figured out what some of the values I see are, but I'm not sure if I'm catching all the relevant TuyaMCU outputs. I feel like it shouldn't be this hard to identify what values are what if I got all the data into some channel, even if it's incorrectly divided, as long as any division/multiplier is 10-based.

    Will all TuyaMCU values always display, or only the ones specified and mapped to a channel in autoexec.bat?

    I'll see if I can connect my second non-flashed device to the Tuya app/cloud to see if I can find more dPID info that way. As a newbie, I'm 100% sure if dPIDs are the same thing as the TuyaMCU outputs I'm trying to identify, but since I know some, it wouldn't be too difficult to verify at a glance. Is the Tuya dPID output the JSON data you are referring to? If so, I should be on the right track.
  • #6 21906126
    vincenzoernst1
    Level 9  
    Posts: 96
    Help: 3
    Rate: 7
    sometimes you have to nudge the mcu send all data...but i always forgett the openbeken setting....let me check

    tuyaMcu_defWiFiState 4 // to tell mcu cloud is connected
  • ADVERTISEMENT
  • Helpful post
    #7 21906169
    John_SolderWick
    Level 5  
    Posts: 6
    Help: 1
    Rate: 1
    I think I figured it out.

    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

    Based on what was available in the Tuya developer portal device log dropdown, there's a lot less dPIDs for this device. But all the basic info is now available.

    Here's the mapping:
    
    1   Total forward energy
    6   Phase A
    7   Phase B
    8   Phase C
    9   Alarm
    12  ZERO ENERGY (no data in dev-portal logs)
    17  Alarm set1
    18  Alarm set2
    19  Product ID (Shown as SPM02_555D)
    23  Total Reverse Energy (no data in dev-portal logs)
    29  Total Active Power (no data in dev-portal logs)
    32  Frequency (no data in dev-portal logs)
    35  Online state (no data in dev-portal logs)
    50  Overall Power Factor (no data in dev-portal logs)
    102 Voltage X
    103 Current X
    104 Actuve Power X
    105 Voltage Y
    106 Current Y 
    107 Actuve Power Y 
    108 Voltage Z 
    109 Current Z 
    110 Actuve Power Z 



    [EDIT]
    I just realized the second device I had connected to the tuya cloud had some updates available.
    Main module version was 2.1.6 (I assume this is the firmware that gets replaced by OpenBeken anyway) and got updated to 3.1.42
    More interestingly the MCU module version was v4.0.5, and I could update it two times, first to v4.0.8, and then to 4.0.9.
    There's no new dPIDs in the Tuya dev portal after updating, but some of the IDs that had no log/reported data in the portal have it now after the updates.

    I don't know what MCU version is in the one I already flashed to OpenBeken. I think I might have updated that one through the Tuya app, but that was probably 10 months ago, so I'm not sure if it's running the latest version. Maybe I'll try switching the CB2S modules between them and see if the one still running Tuya firmware can read and update the MCU module version on the first device as well.
  • #8 21906301
    vincenzoernst1
    Level 9  
    Posts: 96
    Help: 3
    Rate: 7
    >>21906169

    nice finding! jep, there seems to be a fw update of the mcu going on. a swap will healp clearing thing up.
  • #9 21906433
    John_SolderWick
    Level 5  
    Posts: 6
    Help: 1
    Rate: 1
    @divadiow
    I took the second one apart and de-soldered the top PCB.

    There are two ICs, and they had some type of conformal coating on them. The coatings on the bigger IC had an uneven finish, so I had to scrape it off to be able to see the markings, but it was still really hard to read.

    With the top PCB removed:
    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

    Best picture I managed to get with my phone of the bigger IC:
    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter

    The markings are:
    BL6552
    2301 YH
    D82 22016

    While searching for BL6552 I found this Polish forum thread that includes a picture where markings are clearer:
    https://forum.arturhome.pl/t/dwukierunkowy-3-fazowy-licznik-energii-spm02-d2tw/10961/47

    Just the D82 that I got wrong and thought it was 082.

    Apparently it's "a 7-channel three-phase power monitoring and analysis chip".
    https://www.alibaba.com/product-detail/BL6552...ginal-Energy-Metering-Data_1601214807755.html

    The other IC is a Novuton MINI57TDE that contains an ARM Cortex core, this must be the MCU.

    [CB2S/BK7231N] ZGMISMART-SPM02 v2 - OpenBeken Tuya 3-Phase Powermeter
  • #10 21910408
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14604
    Help: 654
    Rate: 12620
    Interestingly enough, BL6552 is using UART communication. So it could work directly with OBK, once we provide a driver. TuyaMCU could be omitted.
    Screenshot of BL6552 documentation: section 5.2 UART with baud-rate table and per-byte frame diagram
    I am attaching BL6552 datasheet.
    Attachments:
    • BL6552_V1.12_en.pdf (1.68 MB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.

Topic summary

✨ Discussion about OpenBeken support for a Tuya 3-phase power meter (ZGMISMART-SPM02) based on CB2S/BK7231N. A custom autoexec.bat is shared to start the TuyaMCU and httpButtons drivers, emulate cloud Wi‑Fi state, and map multiple Tuya MCU datapoints to OpenBeken channels for energy forward/reverse totals, frequency, current unbalance, total power, power factor, and additional measurements. Testing with a simulated 1-phase load setup showed unclear results, and it was questioned whether the device requires a true 3-phase connection with balanced phasors. Further troubleshooting focused on verifying the JSON datapoint IDs against the autoexec.bat mappings and using equal loads on all phases to validate correct operation.
Generated by the language model.
ADVERTISEMENT