logo elektroda
logo elektroda
X
logo elektroda

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

mihcc 1401 3
ADVERTISEMENT
  • 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

    Cool? Ranking DIY
    About Author
    mihcc
    Level 2  
    Offline 
    mihcc wrote 2 posts with. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20940161
    p.kaczmarek2
    Moderator Smart Home
    Thank you for posting the teardown. I can try to help with your issues:
    mihcc wrote:

    1. It appears that LED light shows as Button. If I toggle the blue light turns on and off, without any relay changes

    That's how you have it configured:
    
      "pins": {
        "7": "Rel;3",
        "8": "LED;0",
        "10": "Btn_Tgl_All;0",
        "24": "Rel;2",
        "26": "Rel;1"
      },
    

    I would rather suggest changing LED role to WiFiLED_n.

    mihcc wrote:

    2. Btn Toggle All is missing in web gui
    3. Is it possible to include Btn toggle all to Home Assistant using mqtt?

    Toggle all is for physical buttons, you are the first one to request having it on GUI. Still, I can add it, if you think that may be useful. That being said, I'll just note here that's the same as in Tasmota, I haven't seen Tasmota having "toggle all" on GUI.

    mihcc wrote:

    4. How can I configure the relay's last state? After wifi reconnects, Relay 0 is switched on, but USB relays are off.

    You can either use "Configure startup" menu to setup start value as 0, 1 or "remember last state" (-1), or you can script it in autoexec.bat
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20940833
    mihcc
    Level 2  

    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 with this configuration, it's turned off. And only the red LED is active if the AC plug is active (Relay 1).
    2. It's okay. I will use HA group turn on/off, which is okay.
    3. I did try this before, and now it's working. I don't know why I was having issues prior. At least for reboot. I'll check if it fails after wifi loss and reconnect.
    I assume that Channel 0 is for WifiLED? So I configured 1-3 to the last state:
    Interface for configuring initial channel values in an application.
  • #4 20940853
    p.kaczmarek2
    Moderator Smart Home
    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 page because you may have accidentally set something for channel 0 like Btn_Tgl_All and maybe GUI is a bit naive and it shows it anyway even tough it's not really used.

    I don't think it's a problem, it's just a matter of cosmetics.
    Helpful post? Buy me a coffee.
ADVERTISEMENT