As for MQTT, you can execute command again and it will publish this JSON under stat topic, see self test:
Also remember that you can request only single dpID by doing command like:
DP23
This will publish only dpID 23, not the full list.
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam
DP23
Angel0fDeath wrote:I think, if @morgan_flint confirms this version works on the other device too, you can release it.
Quote:Changes
increase MQTT_MAX_QUEUE_SIZE to 32 to support 16 relay devices (1683343)
Tuyamcu raw access (#1048) (55e2a66), closes #1048
Assets
// start TuyaMCU driver
startDriver TuyaMCU
tuyaMcu_setBaudRate 9600
// This one is better than tuyaMcu_defWiFiState 4; MQTTState 1 = WiFiState 4
// issuing of tuyaMcu_defWiFiState 4 continues the script,
// but doesnt report to MQTT since there is still no connection.
// if you didn't setup MQTT connection then issue tuyaMcu_defWiFiState 4
// and comment waitFor MQTTState 1
waitFor MQTTState 1
// tuyaMcu_defWiFiState 4
// Breaker Id - Dpid 19 "breaker_id" - channel 0
linkTuyaMCUOutputToChannel 19 3 0
setChannelType 0 ReadOnly
setChannelLabel 0 "Breaker ID"
// Total energy - Dpid 1 "total_forward_energy" - channel 1
linkTuyaMCUOutputToChannel 1 val 1
setChannelType 1 EnergyTotal_kWh_div100
setChannelLabel 1 "Total Energy"
// Measurements - Dpid 6 "phase_a" - channel RAW_TAC2121C_VCP -> 2,3,4
// TAC2121C VoltageCurrentPower Packet
// This will automatically set voltage, power and current
linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP
setChannelType 2 Voltage_div10
setChannelLabel 2 "Voltage"
setChannelType 3 Power
setChannelLabel 3 "Power"
setChannelType 4 Current_div1000
setChannelLabel 4 "Current"
// Leakage current - Dpid 15 "leakage_current" - channel 15
linkTuyaMCUOutputToChannel 15 val 5
setChannelType 5 LeakageCurrent_div1000
setChannelLabel 5 "Leakage Current"
// Fault - Dpid 9 "fault" - channel 9
linkTuyaMCUOutputToChannel 9 val 9
setChannelType 9 ReadOnly
setChannelLabel 9 "Fault"
// Prepayment on-off - Dpid 11 "switch_prepayment" - channel 11
linkTuyaMCUOutputToChannel 11 bool 11
setChannelType 11 toggle
setChannelLabel 11 "Prepayment"
// Clear Prepayment - Dpid 12 "clear_energy" - channel 12
linkTuyaMCUOutputToChannel 12 bool 12
setChannelType 12 toggle
setChannelLabel 12 "Clear Prepayment"
// Prepaid energy - Dpid 13 "balance_energy" - channel 13
linkTuyaMCUOutputToChannel 13 val 13
setChannelType 13 EnergyTotal_kWh_div100
setChannelLabel 13 "Total Prepaid Energy"
// Charge Prepayment - Dpid 14 "charge_energy" - channel 14
setChannelType 14 textfield
setChannelLabel 14 "Purchased Energy [kWh*100], i.e. 1kWh = 100"
linkTuyaMCUOutputToChannel 14 val 14
// Main Relay - Dpid 16 "switch" - Channel 16
linkTuyaMCUOutputToChannel 16 bool 16
setChannelType 16 toggle
setChannelLabel 16 "Relay"
// Settings 1 - Dpid 17 "alarm_set_1" - channel 17
linkTuyaMCUOutputToChannel 17 raw 17
setChannelType 17 textfield
setChannelLabel 17 "Leakage Current Protection Settings"
// Settings 2 - Dpid 18 "alarm_set_2" - channel 18
linkTuyaMCUOutputToChannel 18 raw 18
setChannelType 18 textfield
setChannelLabel 18 "UV, OV, Max. Current Protections Settings"
// Test Leakage - Dpid 21 "leakagecurr_test" - channel 21
linkTuyaMCUOutputToChannel 21 bool 21
setChannelType 21 toggle
setChannelLabel 21 "Test Leakage"
// Clear all energy - Dpid 101 "clr_all_energy" - channel 23
linkTuyaMCUOutputToChannel 101 bool 23
setChannelType 23 toggle
setChannelLabel 23 "Clear all energy counters"
// Power factor - Dpid 104 "power_factor" - channel 24
linkTuyaMCUOutputToChannel 104 val 24
setChannelType 24 PowerFactor_div1000
setChannelLabel 24 "Power Factor"
// Grid frequency - Dpid 105 "supply_frequency" - channel 25
linkTuyaMCUOutputToChannel 105 val 25
setChannelType 25 Frequency_div10
setChannelLabel 25 "Frequency"
// NOTE: addRepeatingEvent [RepeatTime] [RepeatCount]
// code below will forever Send query state command every 5 seconds
addRepeatingEvent 5 -1 tuyaMcu_sendQueryState
// AngelOfDeath - We don't need it forever, since TuyaMCU sends everything when necessary
// we need it just first time to obtain initial status. Some dpIDs not reported without asking
// tuyaMcu_sendQueryState
Quote:And the screenshot of OBKs main page:
[BK7231N ] Teardown and flashing of Tomzn TOMPD-63 WIFI (not to be confounded with TOMPD-63LW)
Quote:We could make a separate topic in "Teardowns" section for that, so it's not lost on the fourth page of discussion.
"Status": {
"Module": 0,
"DeviceName": "Breaker",
"FriendlyName": [
"Main Breaker"
],Quote:@morgan_flint I'm playing with faults. It looks like there is some internal recovery time in tuyaMCU before next fault can be discovered - i.e. when you simulate fault - wait about 10-15 sec. before simulating next fault. Obviously in real life you cannot have faults so fast and probably this is the reason they don't read the inputs so often.... Don't really sure, but please check and confirm.
Also on this device, if protection is OFF the device even didn't break the line. In general - now you can set and test everything. Please make full tests.
Angel0fDeath wrote:"Status": { "Module": 0, "DeviceName": "Breaker", "FriendlyName": [ "Main Breaker" ],
(...)
I also don't know why FriendlyName is an array - there are []. Is this really necessary?
Quote:I'm not sure about that swap, I will check this out, but it may be late to change now.
Quote:This JSON format was not designed by me, it's just made to mimic Tasmota standard. That's why Tasmota Control/Tasmotrol/Tasmota Remota etc apps are working with OBK:
"Status": {
"Module": 0,
"DeviceName": "IR_TH1",
"FriendlyName": [],
"Topic": "IR_TH1",
"ButtonTopic": "0",Angel0fDeath wrote:Probably is good idea to add clearIO command in the beginning of the script. This will clear all previous definitions. Or set these channels manually to Default in web app -> config
Angel0fDeath wrote:@morgan_flint Ok. I've got it. In order to process correct the event when tuyaMCU changes from 1 byte report up to 4 bytes report for dpID9 (fault) this dpID should be of type RAW. Then, at least by me everything is processed ok.
I'm attaching the corresponding autoexec.bat and Breaker.html rev.5
Nevertheless please check again with your devices and report.
Quote:I also did some experiments with the other device. As DpIDs 104 and 105 have another meaning, I commented out the corresponding lines in your autoexec. The Breaker_rev5.html didn't seem to work well, the measurements were not shown and, regarding protections' settings, it seemed to have a random behavior. I'll make some more tests and report after a second look at the autoexec
Angel0fDeath wrote:1. When you set purchased energy in the device, the device remembers this value (dpid 14). After that if you want to use the same value - not possible - you need to change it. Since setting this dpid ADDS the value to dpid 13, I found work around - first set the value of dpid 14 with user input, then reset the value with 0 (automatically) for dpid 14. Can you please test it is the same for you on your both devices
Angel0fDeath wrote:@morgan_flint There is no command to ask for just 1 dpID state.
55 aa 00 08 00 00 07
TL;DR: 13 data-points (DpIDs) can be remapped, flashed in 90 s, and “a good platform for experimenting and hacking” [Elektroda, morgan_flint, post #20869137] How-to below uses only 4 GPIO pins. Why it matters: you gain offline control, MQTT and Home-Assistant auto-discovery without Tuya cloud.
• Rated 63 A, 230 V AC single-pole switching [Elektroda, morgan_flint, post #20869137] • BL0942 energy SoC ±1 % kWh class (Vango 2021 datasheet) • Magnetic latching relay: <50 ms actuation, no hold current [Elektroda, morgan_flint, post #21510731] • Flash size 2 MB; LittleFS frees ≈70 kB after v1.18.72 [Elektroda, pexicele, post #21504906] • Street price €11.56-19 delivered [Elektroda, morgan_flint, post #20931165]
uartprogram -r). 3. Write merged image (OpenBK7231N_QIO_xxx.bin) with -w --unprotect -s 0x0; flashing takes ≈90 s at 115 kbit [Elektroda, leśny_ziutek, post #21309399]linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP 5 then set channels 5-7 as V-C-P [Elektroda, mr_crabs, post #21363680]linkTuyaMCUOutputToChannel 6 val 5 0 1000 0 5 where the last two values are scale (×1.000) and delta (-5 V) [Elektroda, p.kaczmarek2, post #21491237] Display values on the LCD stay factory; only MQTT/web data change./cm?cmnd=Dp. OBK replies with JSON array {id,type,data}; raw types are hex strings [Elektroda, p.kaczmarek2, post #20924258]autoexec.bat, run clearIO and reboot. 2. Open 192.168.4.1, set Wi-Fi, then MQTT and Start Home Assistant Discovery. 3. Upload TOMPD-63-WIFI_rev7.html via Filesystem → Upload and access at /api/lfs/TOMPD-63-WIFI_rev7.html [Elektroda, Angel0fDeath, post #20988474]flags 0 over the open WebSocket or power-cycle into safe-mode after 10 short boots [Elektroda, Angel0fDeath, post #20933777]