logo elektroda
logo elektroda
X
logo elektroda

Tuya ATORCH S1-BWTH (BK7231N) OpenBeken: Relay Toggle Not Switching via Web UI

krislkins 150 8
ADVERTISEMENT
  • #1 21566733
    krislkins
    Level 3  
    Hello Everyone, this my first post, so please be gentle. First of all, thank you to the people in the community creating and maintaining openbeken.

    After researching on solutions for monitoring power for my 3D printers, I ended up buying several of these

    Tuya ATORCH S1-B/W/T/H Smart Socket Energy Monitor (BK7231N) (C3BS)

    With help from articles on this forum I have been able to desolder the C3BS, flash openbeken with a TTL USB via Linux machine. Now I have a lovely closed-loop means to monitor my 3d printer farm power consumption with stats sent via MQTT to a Raspberry Pi running LibreNMS, and a custom app that draws nice graphs. (Openbeken -> MQTT -> perl script -> snmp -> LibreNMS custom app).

    My issue that I need some help with:
    I would like to now know why (and how to fix) the "toggle" on the interface for the power meter though, I have the channel 1 set for toggle, and I have the meter in "controlled" mode, pressing the button to toggle the relay definitely powers it off (and back on again), I can observe that openbeken sees the state change from 0 to 1 etc, but I click "Toggle on", this also changes the state and the button goes green/red etc, but the relay does not switch. I must have an error somewhere, or is an unsupported feature. it is the same on all four of my Atorch S1s...

    Would someone be able to point me in the right direction or where to start trying to troubleshoot this? Here is my autoexec for info:

    startDriver TuyaMCU
    startDriver NTP
    tuyaMcu_setBaudRate 115200
    setChannelType 1 toggle
    setChannelType 2 Voltage_div100
    setChannelType 3 Power_div100
    setChannelType 4 Current_div1000
    setChannelType 5 Frequency_div100
    setChannelType 6 EnergyCost_div1000
    setChannelType 7 Temperature
    setChannelType 8 PowerFactor_div100
    setChannelType 9 EnergyTotal_kWh_div1000
    //ch 1 (dpid 1) power relay control
    linkTuyaMCUOutputToChannel 1 bool 1
    //ch 2(dpid 20) voltage
    linkTuyaMCUOutputToChannel 20 1 2
    //ch 3(dpid 19) power watts
    linkTuyaMCUOutputToChannel 19 1 3
    //ch 4 (dpid 18)current Amps
    linkTuyaMCUOutputToChannel 18 1 4
    //ch 5 (dpid (133) frequency
    linkTuyaMCUOutputToChannel 133 1 5
    //ch 6 (dpid 102) energy cost used
    linkTuyaMCUOutputToChannel 102 1 6
    // ch 7 (dpid 135) temp
    linkTuyaMCUOutputToChannel 135 1 7
    //ch 8 (dpid 134) power factor
    linkTuyaMCUOutputToChannel 134 raw 8
    //ch 9 (dpid 123) energy consumed
    linkTuyaMCUOutputToChannel 123 1 9

    All the meters are running 1.07 on the MCU as far as I can tell, thats what the config menu tells me.

    thanks in advance
    AI: Have you tried toggling the relay using other OpenBeken interfaces, such as MQTT commands or the HTTP API, and if so, does the relay switch as expected through those methods?
    I have not, however the log indicates that something is being picked up and this shows the that the value toggles (probably causing the state to observed as changing on the home page)
    AI: When you attempt to toggle the relay via the web UI, do you see any errors or unusual messages in the OpenBeken logs or debug output that might indicate what's going wrong?
    Nothing obvious, but I'm not totally show
    Do you have a problem with Raspberry? Ask question. Visit our forum Raspberry.
  • ADVERTISEMENT
  • #2 21566743
    p.kaczmarek2
    Moderator Smart Home
    Do you have original 2MB flash backup so we can do dpID extraction? https://www.elektroda.com/rtvforum/topic4021129.html
    Your config looks okay, but maybe dpID 1 is read only and there is another dpID you need to set?
    Was it working in Tuya App?
    Maybe try requesting dpIDs. You can also enable store flag and use command to view them:
    https://www.elektroda.com/rtvforum/topic3995777-60.html#20955894
    https://www.elektroda.com/rtvforum/topic3959907-60.html#20976537
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21566818
    krislkins
    Level 3  
    Hi, thanks for your reply. Checking my work back in Oct 2024 when I did my first one, it looks like I tried to backup the firmware but looks like I was having problems. My command history seems to indicate I ran uartprogram -r like 20 times, each time ended up with a file that is always 1150976 bytes, but the checksum is different every time, so looks I may have given up trying to back it up maybe because an error was occurring during that.

    I'm presuming I can't get the original now (unless I get another one unit, which I am planning to in all honesty). I only used the smart life app for the first one, which sparked my investigation into getting away from Tuya cloud, that certainly provided the capability of remotely changing the power state for the relay from the app.

    I anticipate yes, there must be a different ID to try and set, and maybe the number 1 one is as you mentioned read only... the issue I have is my familiarity of this, and I'm danger of sounding a bit user-space by asking the question. I will have a perusal of those links and see if I can figure out a way, I have a feeling it will be trial and error with my limited knowledge.

    Update... so after having a bit of a read I also came across this article (by your good self it appears) https://www.elektroda.com/news/news4049908.html# but I don't think I can see the relevant bits to copy/paste into my autoexec in order to capture the dpids. I tried enabling 46 and 47 in the config module section, and if I run tuyaMcu_sendQueryState I do get some errors in the log indicating not enough space in the array.

    Would it be worth trying to trial and error it? I suppose it's find a needle in a haystack... I've also had a look on the tuya developer platform, but sadly my device is no longer listed in there so I can't export the dpids from there.
  • ADVERTISEMENT
  • #5 21566877
    krislkins
    Level 3  
    Yes, it is indeed that device from https://www.elektroda.com/rtvforum/topic4003739-30.html#21005755 (although I opted to remove the C3BS from the board to flash it).

    I had a scan through that post quite a bit, and the autoexec I am using pretty much uses the useful values from the below:

    DP 1, BOOL(rw), switch_1 (开关状态)
    DP 9, VALUE(rw), countdown_1 (开关倒计时)
    DP 17, VALUE(rw), add_ele (增加电量)
    DP 18, VALUE(ro), cur_current (当前电流)
    DP 19, VALUE(ro), cur_power (当前功率)
    DP 20, VALUE(ro), cur_voltage (当前电压)
    DP 101, VALUE(rw), price (电费单价设置)
    DP 102, VALUE(ro), cost (总电费)
    DP 103, VALUE(ro), add_cost (电费)
    DP 104, VALUE(rw), ovp (过压值)
    DP 105, VALUE(rw), ocp (过流值)
    DP 106, VALUE(rw), opp (过功率值)
    DP 107, ENUM(rw), language (设备语言)
    DP 108, VALUE(rw), work_value (工作屏幕亮度)
    DP 109, VALUE(rw), standby_value (待机屏幕亮度)
    DP 110, VALUE(rw), standby_time (进入待机时间)
    DP 111, BOOL(rw), beep (系统声音)
    DP 112, ENUM(rw), sw_mode (开关模式)
    DP 113, BOOL(rw), data_reset (累计数据清零)
    DP 114, BOOL(rw), wifi_reset (WiFi设备重置)
    DP 115, BOOL(rw), factor_reset (恢复出厂设置)
    DP 116, BOOL(rw), screen_rotation (屏幕旋转)
    DP 117, ENUM(rw), standby_screen (待机画面)
    DP 118, ENUM(rw), menu (设备功能页面选择:)
    DP 119, VALUE(rw), plow (功率小于)
    DP 120, VALUE(rw), time_a (并持续时间(A类))
    DP 121, VALUE(rw), phigh (功率大于)
    DP 122, VALUE(rw), time_b (并持续时间(B类))
    DP 123, VALUE(ro), ele (总电量)
    DP 124, VALUE(ro), run_countdown (自动运行倒计时)
    DP 125, VALUE(rw), timing_close (定时关闭时间)
    DP 126, VALUE(rw), timing_open (定时开启时间)
    DP 127, VALUE(rw), loop_open (循环定时先开时间)
    DP 128, VALUE(rw), loop_close (循环定时再关时间)
    DP 129, VALUE(rw), countdown_open (倒计时开时间)
    DP 130, VALUE(rw), countdown_close (倒计时关时间)
    DP 131, ENUM(rw), r_mode (开关)
    DP 132, ENUM(rw), warning (告警标志)
    DP 133, VALUE(ro), cur_frequency (当前频率)
    DP 134, VALUE(ro), power_factor (功率因数)
    DP 135, VALUE(ro), cpu_temp (仪表CPU温度)
    DP 136, ENUM(rw), price_mode (电费模式选择:)
    DP 137, VALUE(rw), over_time (超限电压恢复延时:)
    DP 138, ENUM(rw), ttl (设备上电开关状态:)
    DP 139, VALUE(rw), reporting_interval (测量数据刷新间隔时间)

    noting that 1 is a boolean is listed as rw and is for the toggle. but maybe its something else... interestingly, if I try to adjust channel 1:

    //ch 1 (dpid 1) power relay control
    linkTuyaMCUOutputToChannel 1 bool 1

    to target another BOOL value (I've chosen screen rotation #116), after restarting the device to make sure its all ok, if I hit the toggle, the screen does rotate. But only once! The button doesn't go green either... I can only get back by manually setting screen rotation back on the device. If I change to 111 (beep), then toggle on, goes to green, and that toggles beeps on (which are already enabled) toggling again goes to red and turns beeps off. So that value works nicely, just not useful.

    Edit: thanks for the video for how to dump the gpio config, I have done this and attached the bin file
  • ADVERTISEMENT
  • #7 21568483
    krislkins
    Level 3  
    Thanks very much for looking at that for me, that's interesting about the firmware, and also very interesting about the private key, I would have rationally thought these would be different across devices, so if they are the same, that sounds There is clearly a lot more I don't understand how this is put together, but from your post it sounds like I need to perhaps downgrade this 3.1.17 firmware to the one that you provided a bin file for? That looks like it's the "2M" file you were referring to in an earlier post, so would I need to low level flash that 2M file to the CB3S just like I did with the original OBK, or can that be done OTA?
  • #8 21568510
    divadiow
    Level 34  
    krislkins wrote:
    but from your post it sounds like I need to perhaps downgrade this 3.1.17 firmware to the one that you provided a bin file for?

    ah, negative. that was just an observation. from the confirmation the product key is the same you can be more confident about the dpIDs for this device are what were posted in the other thread.

    if you flashed the 2.1.6 backup you'd just be back to stock Tuya firmware
  • #9 21568524
    krislkins
    Level 3  
    right you are, I won't do any flashing in that case, good to know that it's the same product though. thank you.. so could it be a bug in the manufacturer firmware then, a stealthy unknown dpid, or it is simply read only? after testing the other bool values, I got different confirmation on the toggling, screen rotation works for example (but only on one direction and refuses to toggle back), and the "beep" does toggle. I've not tried to bind the toggle to any other dpid that isn't BOOL though, to see if that works but I can't see any other valid description for what would probably be the main switch relay apart from dpid 1...

    I've also tried adjusting the configuration from "controlled" to "always on", but toggle still doesn't switch the relay, the only difference is that it can no longer be switched using the - buttons on the front of the device if not set to controlled... so it's not that either it would appear.
ADVERTISEMENT