logo elektroda
logo elektroda
X
logo elektroda

Configuring AliExpress 16A USB Socket with CB2S (BK7321N) and Tuya JSON Code

mihcc  3 1836 Cool? (0)
📢 Listen (AI):

TL;DR

  • An AliExpress 16A USB socket with a CB2S module and BK7231N chip is mapped, with a slightly different pinout and three relays.
  • Tuya extraction assigns relay channels to P7, P24, and P26, with the pair/toggle-all button on P10 and the Wi‑Fi LED on P8.
  • The Tuya section starts at 2023424, and the OpenBeken template targets BK7231N with pins 7, 8, 10, 24, and 26.
  • OpenBeken still has issues: the blue LED behaves like a button, Btn Toggle All is missing in the web GUI, and relay state after Wi‑Fi reconnect is unresolved.
Generated by the language model.
Hi,

Recently I have bought this socket https://www.aliexpress.com/item/1005005583141499.html?spm=a2g0o.order_list.order_list_main.88.26e8180268ZrMC which is similar to https://www.elektroda.com/rtvforum/topic3892473.html#20014441 with some differences. Pinout is slightly different and has 3 relays.

Device configuration, as extracted from Tuya:
- Relay (channel 3) on P7
- Pair/Toggle All Button on P10
- WiFi LED on P8
- Relay (channel 2) on P24
- Relay (channel 1) on P26
Device seems to be using CB2S module, which is using BK7231N.
And the Tuya section starts, as usual, at 2023424

This is json code:
{
	"rl1_lv":"1",
	"bt_type":"0",
	"rl3_pin":"7",
	"rl3_lv":"1",
	"net_trig":"2",
	"jv":"1.0.0",
	"netled1_lv":"0",
	"netled_reuse":"0",
	"total_bt_pin":"10",
	"nety_led":"1",
	"total_stat":"2",
	"reset_t":"5",
	"netled1_pin":"8",
	"rl2_lv":"1",
	"module":"CB2S",
	"ch_cddpid1":"9",
	"rl2_pin":"24",
	"ch_cddpid2":"10",
	"ch_cddpid3":"11",
	"total_bt_lv":"0",
	"ch_num":"3",
	"rl1_pin":"26",
	"ch_dpid3":"3",
	"netn_led":"0",
	"ch_dpid1":"1",
	"ch_dpid2":"2",
	"crc":"59",
	"}4 &Agw_di{abi":"0",
	"id":"null",
	"swv":"1.1.15",
	"bv":"40.00",
	"pv":"2.2",
	"lpv":"3.4",
	"pk":"keyjup78v54myhan",
	"firmk":"keyjup78v54myhan",
	"cadv":"1.0.5",
	"cdv":"1.0.0",
	"dev_swv":"1.1.15",
	"s_id":"null",
	"dtp":"0",
	"sync":"0",
	"attr_num":"1",
	"mst_tp_0":"9",
	"mst_ver_0":"1.1.15",
	"mst_md5_0":"null",
	"mst_tp_1":"0",
	"mst_ver_1":"null",
	"mst_md5_1":"null",
	"mst_tp_2":"0",
	"mst_ver_2":"null",
	"mst_md5_2":"null",
	"mst_tp_3":"0",
	"mst_ver_3":"null",
	"mst_md5_3":"null }0Atls_ca_cnt0 .MAgw_wsm{nc_tp",
	"ssid":"null",
	"passwd":"null",
	"md":"0",
	"random":"0",
	"wfb64":"1",
	"stat":"0",
	"token":"null",
	"region":"null",
	"reg_key":"null",
	"dns_prio":"0 }{uuid",
	"psk_key":"tIifVCRMFEUE4LGN5crm9kUb2D248mljvhK09",
	"auth_key":"TaMAFMiYg6zqkGivWBaiI85WxIH9GeQx",
	"ap_ssid":"SmartLife",
	"ap_passwd":"null",
	"country_code":"null",
	"bt_mac":"null",
	"bt_hid":"null",
	"prod_test":"false",
	"fac_pin":"xjibhmsjf3hqrbcc }3Awf_start_mdll",
	"lckey":"null",
	"h_url":"null",
	"h_ip":"null",
	"hs_url":"null",
	"hs_ip":"null",
	"hs_psk":"null",
	"hs_psk_ip":"null",
	"mqs_url":"null",
	"mqs_ip":"null",
	"mq_url":"null",
	"mq_ip":"null",
	"ai_sp":"null",
	"ai_sp_ip":"null",
	"mq_psk":"null",
	"mq_psk_ip":"null",
	"lp_url":"null",
	"lp_ip":"null",
	"time_z":"null",
	"s_time_z":"null",
	"wx_app_id":"null",
	"wx_uuid":"null",
	"dy_tls_m":"0",
	"cloud_cap":"0",
	"psk21_key":"null }ok5A0000038zlb[{type",
	"mode":"rw",
	"property":"{type",
	"{type":"obj",
	"max":"86400",
	"scale":"0",
	"step":"1",
	"type":"value}",
	"maxlen":"255}",
	"index":"0}@Amf_test_closetrueDNMAgw_ai{key",
	"m3nc_tp":"0"
}


OpenBeken template:
{
  "vendor": "Tuya",
  "bDetailed": "0",
  "name": "Full Device Name Here",
  "model": "enter short model name here",
  "chip": "BK7231N",
  "board": "TODO",
  "flags": "0",
  "keywords": [
    "TODO",
    "TODO",
    "TODO"
  ],
  "pins": {
    "7": "Rel;3",
    "8": "LED;0",
    "10": "Btn_Tgl_All;0",
    "24": "Rel;2",
    "26": "Rel;1"
  },
  "command": "",
  "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
  "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
}


And some pictures
Close-up of a green circuit board with a CB2S module and capacitors.
Image of the inside of a smart socket with visible PCB and electronic components.
White electrical outlet with two USB ports and a power button.
White Wi-Fi Smart Socket with model and specification label.
Close-up view of an electronic device's printed circuit board.
Close-up of a circuit board with electronic components, including relays and a module.

Added after 18 [minutes]:

Because I am new with openbeken I'am seeking some help.
I don't know if I'm doing something wrong:
1. It appears that LED light shows as Button. If I toggle the blue light turns on and off, without any relay changes
2. Btn Toggle All is missing in web gui
3. Is it possible to include Btn toggle all to Home Assistant using mqtt?
4. How can I configure the relay's last state? After wifi reconnects, Relay 0 is switched on, but USB relays are off.

Thank you

About Author
mihcc wrote 2 posts with . Been with us since 2023 year.

Comments

p.kaczmarek2 01 Feb 2024 21:27

Thank you for posting the teardown. I can try to help with your issues: That's how you have it configured: "pins": { "7": "Rel;3", "8":... [Read more]

mihcc 02 Feb 2024 11:45

Hi, Thank you for your fast reply. 1. I changed to LED because I had problems with LED status. Now I changed P8 to WifiLED and it works as expected. I did not want the blue light to be turned on. So... [Read more]

p.kaczmarek2 02 Feb 2024 12:01

Channel 0 is not for WiFi LED. WiFi LED is channel-independent. I think that channel 0 is unused in your case, you have relays set for channel 1, 2 and 3. The channel 0 may be visible on Startup... [Read more]

FAQ

TL;DR: For this 16A, 3-relay CB2S socket, map P7/P24/P26 to relays, P10 to Btn_Tgl_All, and P8 to WiFiLED_n. As the expert said, "change LED role to WiFiLED_n"; that fixes the blue LED behavior, while relay restore state is set in Configure Startup or autoexec.bat. [#20940161]

Why it matters: This FAQ helps OpenBeken users turn a partly decoded Tuya dump into a working, predictable multi-relay socket configuration.

Option Result on this socket Best use
LED;0 on P8 Blue LED appears as a controllable GUI item Manual LED control
WiFiLED_n on P8 LED works as Wi-Fi status and stays channel-independent Correct status indication
Btn_Tgl_All;0 on P10 Physical toggle-all input, no normal GUI control One-button local switching

Key insight: The main fix was not the relay mapping. The important change was assigning P8 to WiFiLED_n, because LED;0 made the blue LED behave like a normal channel control instead of a Wi-Fi status LED.

Quick Facts

  • The socket uses a CB2S module with a BK7231N chip, and the extracted Tuya configuration reports 3 channels, not 1 or 2. [#20939569]
  • The confirmed OpenBeken pin map is P7 = Relay 3, P24 = Relay 2, P26 = Relay 1, P10 = Btn_Tgl_All, and P8 = LED/Wi-Fi LED. [#20939569]
  • The Tuya data block starts at flash offset 2023424, and the JSON includes a 5-second reset value (reset_t=5). [#20939569]
  • The follow-up was posted 18 minutes later, showing the issue was configuration-related rather than a hardware failure. [#20939569]
  • Startup behavior can be set per channel to 0 = off, 1 = on, or -1 = remember last state from the OpenBeken startup settings. [#20940161]

How do I configure an AliExpress 16A USB socket with a CB2S module in OpenBeken when the device has three relays and a different pinout?

Set the socket up as a 3-relay OpenBeken device, not as a standard single-outlet plug. Use this mapping: P7 = Relay 3, P24 = Relay 2, P26 = Relay 1, P10 = Btn_Tgl_All, and P8 = WiFiLED_n. That reflects the extracted Tuya data for this CB2S module and matches the working fix reported in the thread. After mapping, set startup states for channels 1, 2, and 3 as needed. [#20940833]

Why does the blue LED show up like a button in OpenBeken instead of acting as a WiFi status LED on this BK7231N socket?

It shows up like a button because P8 was assigned the normal role LED;0. That role creates a standard controllable LED channel, so toggling it only turns the blue light on or off and does not switch any relay. The fix is to change P8 from LED;0 to WiFiLED_n, which the thread confirms restores expected Wi-Fi status behavior. [#20940161]

What is the correct OpenBeken pin mapping for this Tuya CB2S socket with relays on P7, P24, and P26, the button on P10, and the LED on P8?

The correct mapping is P7 = Rel;3, P24 = Rel;2, P26 = Rel;1, P10 = Btn_Tgl_All;0, and P8 = WiFiLED_n for normal status indication. The original template used LED;0 on P8, but that produced the wrong behavior for the blue LED. The device has 3 relay outputs, so channels 1, 2, and 3 are the relevant startup channels. [#20940161]

What is WiFiLED_n in OpenBeken, and how is it different from assigning a normal LED role like LED;0?

WiFiLED_n is the correct role here for a network-status light, while LED;0 is a normal user-controlled LED channel. "WiFiLED_n" is an OpenBeken pin role that drives a Wi-Fi status indicator, channel-independent and active-low, so it reflects network state instead of appearing as a normal on/off control in the device UI. In this socket, switching P8 to WiFiLED_n fixed the blue LED behavior. [#20940853]

Where did the Btn_Tgl_All control go in the OpenBeken web GUI, and why doesn't it appear for this device?

It did not disappear by mistake; OpenBeken does not expose Btn_Tgl_All as a normal web GUI control for this device. The developer explained that Toggle All is intended for a physical button input, and even Tasmota does not normally show a toggle-all control in its GUI. On this socket, P10 is still valid as Btn_Tgl_All, but it is meant for local hardware action. [#20940161]

In what way can I expose a Toggle All function from OpenBeken to Home Assistant over MQTT for a multi-relay Tuya socket?

The thread’s practical workaround is to avoid exposing Btn_Tgl_All itself and use a Home Assistant group instead. The user accepted that approach and planned to use HA group turn on/off for all three relay channels together. That gives equivalent whole-device control over MQTT without needing a dedicated Toggle All GUI entity from OpenBeken. [#20940833]

How can I make the relays remember their last state after reboot or WiFi reconnect in OpenBeken?

Use OpenBeken startup settings or autoexec.bat to define each relay’s boot behavior. You can set a channel to 0 for off, 1 for on, or -1 to remember the last state. For this socket, only channels 1, 2, and 3 matter, because those are the three relay channels. That is the supported way to stop Relay 1 from turning on unexpectedly after reconnects. [#20940161]

What does channel 0 mean in OpenBeken startup settings, and why might it appear even when my relays use channels 1, 2, and 3?

Channel 0 is unused for the relays in this socket. The expert explained that WiFi LED is channel-independent, while the relays are on channels 1, 2, and 3. Channel 0 may still appear on the Startup page because a role such as Btn_Tgl_All was assigned with ;0, and the GUI shows it even though it has no real relay function here. [#20940853]

How do I use the Configure Startup menu or autoexec.bat in OpenBeken to set startup states to off, on, or remember last state?

Use either the GUI or a startup script.
  1. Open Configure Startup and find the relay channels.
  2. Set each channel to 0, 1, or -1.
  3. Save the values, or script the same behavior in autoexec.bat.
In this thread, the developer explicitly states that 0 means off, 1 means on, and -1 means remember last state. For this device, apply those settings to channels 1, 2, and 3. [#20940161]

What is the CB2S module, and how does it relate to the BK7231N or BK7321N chip naming used for Tuya devices?

CB2S is the Tuya Wi-Fi module installed in this socket, and the post identifies it as using BK7231N. "CB2S" is a Tuya wireless module that hosts the device firmware and pin mapping, the key hardware block OpenBeken must match when you build a template or decode Tuya flash data. The thread title mentions BK7321N, but the extracted device data and teardown note CB2S with BK7231N. [#20939569]

How do I extract and interpret the Tuya JSON code from flash to build an OpenBeken template for a smart socket?

Read the Tuya configuration from flash, then copy the pin values into an OpenBeken template. In this case, the post says the Tuya section starts at offset 2023424 and lists rl3_pin=7, netled1_pin=8, total_bt_pin=10, rl2_pin=24, and rl1_pin=26. Those values directly produce the template pins for the three relays, the button, and the LED role. [#20939569]

Tasmota vs OpenBeken for a Tuya CB2S multi-relay socket — which one is better when you need custom pin roles and Home Assistant integration?

OpenBeken is the better fit in this thread because the socket already has a working custom pin map and startup controls inside OpenBeken. Tasmota only appears as a comparison point: the developer notes that Tasmota also does not show a Toggle All control in its GUI. For this exact 3-relay CB2S socket, the thread provides a complete OpenBeken path and a Home Assistant workaround using HA groups. [#20940161]

Why might Relay 1 turn on after WiFi reconnect while the USB relays stay off, even when the device seems configured to restore state?

Relay 1 can turn on if startup state handling is not set correctly per relay channel. The user reported that after Wi-Fi reconnect, Relay 0 turned on while the USB relays stayed off, but the expert clarified that channel 0 is not a real relay channel here. The practical fix is to configure channels 1, 2, and 3 explicitly, because those map to the actual three relays. [#20940853]

What is Btn_Tgl_All in OpenBeken, and how is it intended to work with a physical button on pin P10?

Btn_Tgl_All is the local hardware input that toggles all relay channels from one physical button. "Btn_Tgl_All" is an OpenBeken button role that listens to one GPIO input and applies a shared toggle action, its key characteristic being device-wide switching instead of controlling a single relay channel. On this socket, that role belongs on P10 and is intended for the real front-panel button, not a normal GUI switch. [#20940161]

Which safety checks should I do before reflashing or reconfiguring a mains-powered 16A USB smart socket with exposed relay and AC circuitry?

This thread supports three concrete pre-checks: confirm the module is CB2S, verify the pinout against the teardown photos, and do not assume it matches a similar socket. The first post explicitly says the pinout is "slightly different" and shows exposed internal photos of the relay and mains area. On a 16A AC device, wrong pin mapping can produce false LED behavior or incorrect relay switching after reboot. [#20939569]
Generated by the language model.
%}