Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamp.kaczmarek2 wrote:maybe we can skip the UART capture process which is risky and requires isolation for USB to UART converter, and just try to flash OBK?
morgan_flint wrote:The rest of the hardware seems to be the same (I will add photos later on)
p.kaczmarek2 wrote:Have you tried to look up the full list of datapoints at Tuya developer website?
{"1":"Total forward energy","6":"Phase A","9":"Fault","11":"Switch prepayment","12":"Clear energy","13":"Balance energy","14":"charge energy","15":"Leakage current","16":"Switch","17":"Alarm set1","18":"Alarm set2","19":"Breaker id","21":"Leakage current test","101":"Clear Energy","104":"Power Factor","105":"Grid Frequency","106":"刷新上报","116":"Voltage","117":"Current","118":"有功功率"}| DP Instruction | Standard Instruction | DP ID | Description | total_forward_energy | total_forward_energy | 1 | Total forward energy | phase_a | phase_a | 6 | Phase A | fault | fault | 9 | Fault | switch_prepayment | switch_prepayment | 11 | Switch prepayment | clear_energy | energy_reset | 12 | Clear energy | balance_energy | balance_energy | 13 | Balance energy | charge_energy | charge_energy | 14 | charge energy | leakage_current | leakage_current | 15 | Leakage current | switch | switch | 16 | Switch | alarm_set_1 | alarm_set_1 | 17 | Alarm set1 | alarm_set_2 | alarm_set_2 | 18 | Alarm set2 | breaker_id | breaker_number | 19 | Breaker id | leakagecurr_test | leakagecurr_test | 21 | Leakage current test | clr_all_energy | - | 101 | Clear Energy | power_factor | - | 104 | Power Factor | supply_frequency | supply_frequency | 105 | Grid Frequency | refresh | - | 106 | 刷新上报 (Refresh report) | output_voltage | - | 116 | Voltage | output_current | - | 117 | Current | output_power | - | 118 | 有功功率 (Active Power) |
p.kaczmarek2 wrote:I think we may also need to know the variable types
| DP ID | Code | Type | Values | 1 | total_forward_energy | Integer | {
"unit": "kW·h", "min": 0, "max": 99999999, "scale": 2, "step": 1 } | 6 | phase_a | Raw | {} | 9 | fault | 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" ] } | 11 | switch_prepayment | Boolean | "{true,false}" | 12 | energy_reset | Enum | {
"range": [ "empty" ] } | 13 | balance_energy | Integer | {
"unit": "kW·h", "min": 0, "max": 999999, "scale": 1, "step": 1 } | 14 | charge_energy | Integer | {
"unit": "kW·h", "min": 0, "max": 99999, "scale": 1, "step": 1 } | 15 | leakage_current | Integer | {
"unit": "mA", "min": 0, "max": 1000, "scale": 0, "step": 1 } | 16 | switch | Boolean | "{true,false}" | 17 | alarm_set_1 | Raw | {} | 18 | alarm_set_2 | Raw | {} | 19 | breaker_number | String | {
"maxlen": 255 } | 21 | leakagecurr_test | Boolean | "{true,false}" | 105 | supply_frequency | Integer | {
"unit": "Hz", "min": 0, "max": 1000, "scale": 1, "step": 1 } |
| DP ID | Code | Type | Values | 11 | switch_prepayment | Boolean | "{true,false}" | 12 | clear_energy | Boolean | "{true,false}" | 14 | charge_energy | Integer | {
"unit": "kW·h", "min": 0, "max": 99999, "scale": 1, "step": 1 } | 16 | switch | Boolean | "{true,false}" | 17 | alarm_set_1 | Raw | {} | 18 | alarm_set_2 | Raw | {} | 21 | leakagecurr_test | Boolean | "{true,false}" |
p.kaczmarek2 wrote:This looks somewhat complete, altough I am not sure why dpID 9 is marked as bitmap and not as raw bytes data.
morgan_flint wrote:If this is true, "0" in the reports would be no alarm, and "8" would be "self_test_alarm", which is the 8th in the list (I made some self-tests of the leakage current with the device by pressing the button labeled "T")
morgan_flint wrote:I still have to figure out the meaning of the cryptic values of "Phase A", "Alarm set 1", and "Alarm set 2"
morgan_flint wrote:Following the ideas in this post (specifically, base64 to hex conversion), I think the meaning of "Phase A" is now clear:
setChannelLabel 4 Something
// start TuyaMCU driver
startDriver TuyaMCU
// always force 0x04 WiFi state (paired to cloud), otherwise TuyaMCU might skip some data points
tuyaMcu_defWiFiState 4
startDriver NTP
// let's choose that channel 1 will be main relay state
setChannelType 1 toggle
// label it
setChannelLabel 1 "Relay"
setChannelType 2 Voltage_div10
setChannelType 3 Power
setChannelLabel 3 "Power"
setChannelType 4 Current_div1000
setChannelLabel 4 "Current"
setChannelType 5 EnergyTotal_kWh_div100
setChannelLabel 5 "Energy"
setChannelType 7 toggle
setChannelLabel 7 "Prepayment"
// MF "power factor"
setChannelType 10 PowerFactor_div1000
setChannelLabel 10 "Power Factor"
// MF "supply frequency"
setChannelType 11 Frequency_div100
setChannelLabel 11 "Grid Frequency"
// link id 16 "switch" to channel 1
linkTuyaMCUOutputToChannel 16 bool 1
// link id 1 "total forward energy" to channel 5
linkTuyaMCUOutputToChannel 1 val 5
// TAC2121C VoltageCurrentPower Packet
// This will automatically set voltage, power and current
linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP
// link id 11 "switch prepayment" to channel 7
linkTuyaMCUOutputToChannel 11 bool 7
// MF link id 104 "power factor" to channel 10
linkTuyaMCUOutputToChannel 104 val 10
// MF link id 105 "supply frequency" to channel 11
linkTuyaMCUOutputToChannel 105 val 11
// NOTE: addRepeatingEvent [RepeatTime] [RepeatCount]
// code below will forever toggle relay every 15 seconds
addRepeatingEvent 10 -1 tuyaMcu_sendQueryState setChannelLabel 12 "Leakage Current"
linkTuyaMCUOutputToChannel 15 val 12p.kaczmarek2 wrote:I will add Frequency_div10 for you, but in general, we may consider something more flexible in the future, of course, with backwards-compatibility included
p.kaczmarek2 wrote:I think you need a leakage current channel type for leakage current.
| 55 AA | 03 | 07 | 00 08 | 11 | 00 | 00 04 | 0401001E | 49 | HEADER | VER=03 | State | LEN | dpId=17 | Raw | LEN=4 | V=67174430 | CHK |
| 55 AA | 03 | 07 | 00 10 | 12 | 00 | 00 0C | 01010013 030100FA 040100D2 | 21 | HEADER | VER=03 | State | LEN | dpId=17 | Raw | LEN=12 | Values | CHK |
morgan_flint wrote:BTW, there's a string in the logs (55 AA 03 07 00 10 12 00 00 0C 01 01 00 13 03 01 00 FA 04 01 00 D2 21) that gives an error in TuyaMCUAnalyzer:
p.kaczmarek2 wrote:Good progress, keep it on! I will try to add required channel types tomorrow.
{\ -> {\n
,\ -> ,\n
\" -> "
[{ -> [\n{
}] -> }\n]
]} -> ]\n}p.kaczmarek2 wrote:Yes, please do, we can send you an Elektroda gadget for doing such tutorial. A guide from start to finish, how to get dpIDs.
Still, keep in mind that it may be also possible to use online JSON formatters/beautifiers
TL;DR: 63 A DIN-rail breaker logs 230 V/50 Hz data every 5–10 min, but “addRepeatingEvent 10 -1 tuyaMcu_sendQueryState” cuts it to 10 s [Elektroda, morgan_flint, post #21005072] “Flash first, you can always restore the 2 MB backup” [Elektroda, p.kaczmarek2, post #20693586] Why it matters: Faster, local data means no Tuya cloud and safer automation.
• Rated: 230 V ±10 %, 63 A, <2 W self-consumption [Elektroda, crash1912, post #20693422] • SoC module: WB3S or CBU (BK7231 N/T) with 2 MB flash [Elektroda, crash1912, #20693722; morgan_flint, #20830794] • Factory frame rate: 5 min (V/I/P), 10 min (energy) [Elektroda, morgan_flint, post #21005072] • Supports negative power (export) but still increments kWh [Elektroda, morgan_flint, post #20853227] • DP table: 20 datapoints; key ones → 6-VCP, 11-prepay, 16-relay, 104-PF, 105-Freq [Elektroda, morgan_flint, post #20837470]
linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP and assign channels Voltage_div10, Current_div1000, Power [Elektroda, p.kaczmarek2, post #21364564]linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP 5 (where 5 is your voltage channel). Wrong order swaps current/power and can reopen the relay [Elektroda, morgan_flint, post #21365381]addRepeatingEvent 10 -1 tuyaMcu_sendQueryState to autoexec.bat to poll every 10 s without Tuya cloud traffic.Settings_Prepaid_visibility() to keep it visible and load credit before enabling prepay [Elektroda, morgan_flint, post #21007376]data.find(t=>t.id==21) returns undefined. Add a null check or default r=0 before processing to prevent the UI from breaking [Elektroda, Angel0fDeath, post #20990164]55AA030765… and resets kWh. Relay state is unchanged [Elektroda, Angel0fDeath, post #20990164]