logo elektroda
logo elektroda
X
logo elektroda

Looking for provisioning OpenBeken devices via URL or any other automated procedure

nielspiersma 6435 36
Best answers

Can I provision a freshly flashed OpenBeken device from its AP webpage with a single URL command, like Tasmota backlog, to set pins and network settings automatically?

Yes—OpenBeken can be provisioned from AP mode with a single HTTP URL using `/cm?cmnd=backlog+...`, and the earlier 128-byte HTTP/backlog truncation was fixed so longer command strings now work [#20339711] The basic provisioning commands mentioned are `SetPinRole PIN ROLE` and `SetPinChannel PIN CHANNEL`, and additional commands were added for `ShortName`, `FriendlyName`, `MqttClient`, `SetFlag [bitIndex] [bOn]`, plus Wi‑Fi/MQTT settings such as `SSID1`, `Password1`, and `MqttHost` [#20339004][#20339882][#20340035] A working example shown in the thread was a one-liner that set pin roles/channels, configured Wi‑Fi and MQTT, and then rebooted the unit from the AP page [#20340151] If your browser URL is too long, the thread notes that spaces can be encoded as `%20` and that the old length issue was HTTP-side, not a backlog syntax limit [#20339577][#20341668] Home Assistant discovery still needed to be triggered manually at that point; a dedicated command was planned but not yet present in the thread [#20342271][#20340101]
Generated by the language model.
ADVERTISEMENT
  • #31 20362797
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14611
    Help: 654
    Rate: 12624
    @nielspiersma what do you think about a possibility to write OBK settings directly to binary file, but on Windows (or Linux), before flashing?

    Are you flashing by wire or by OTA hack?

    Btw new UART flashing tool is on the way to release:
    Spoiler:

    Looking for provisioning OpenBeken devices via URL or any other automated procedure
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20362858
    nielspiersma
    Level 9  
    Posts: 60
    Help: 3
    Rate: 20
    p.kaczmarek2 wrote:
    @nielspiersma what do you think about a possibility to write OBK settings directly to binary file, but on Windows (or Linux), before flashing?
    @p.kaczmarek2, we did that in the past with tasmota, but in the end, we concluded that we wanted to use a more standardized approach. I have over 100 ESP82xx in my home now, and every switch is Tasmotized (or BeKenized). And the simple nature of things is that stuff breaks. And it always breaks when you don't want or need it broken. That's why we now have the following approach. The switch is dumb and HomeAssistant controls, so I want to do as little as possible on it and have HomeAssistant control it.

    So we flash the chip and only provision the minimal configuration. Then we connect it to HomeAssistant and inject (via MQTT cmnds) all required configuration settings. So, in the beginning, all devices are equal. Once booted, they get their respective settings. If they break, I can quickly swap them without remembering any specific device-related settings.

    So the only values I would like to write to OBK initial flash would be wifi and MQTT login. That would save the step in AP mode. And have it report directly to HA, ready to receive the configuration. We provision via "script" or "automation' using MQTT publish from there.

    We put a lot of trust into HA; that's why I also was looking for detaching the buttons. We want HA (via MQTT) to toggle the switch.

    Are you flashing by wire or by OTA hack?
    @p.kaczmarek2, both, but I prefer using the OTA hack, as it doesn't require physically opening/damaging the devices. So my approach currently consists of the following; can I open the device without damage? If so, open the device, study it, remove labels, and track the electronics. Add it to Tuya Cloud and recover MCU version number. And finally do cloud-cutter. (post a tear down).

    I investigated, desoldered the tuya board, and downloaded the pristine firmware for cracking. Still, almost all firmware is uploaded now, so there is no real need now.

    But soldering is still on the board.

    Btw new UART flashing tool is on the way to release:
    Spoiler:

    Looking for provisioning OpenBeken devices via URL or any other automated procedure


    Maybe I'll need this for the next Smart device ;). I will give it a try if required.

    Niels
  • ADVERTISEMENT
  • #33 20368287
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14611
    Help: 654
    Rate: 12624
    The flash tool is released:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    I will consider now adding a configuration of flash memory before the flashing - we could just put the Obk config in there already..
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #34 20368476
    nielspiersma
    Level 9  
    Posts: 60
    Help: 3
    Rate: 20
    Thanks for the release. I'll give it a test on the two BK7231 boards I've lying around.
    Niels
  • ADVERTISEMENT
  • #35 20369055
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14611
    Help: 654
    Rate: 12624
    The good thing it does automatic backup of firmware first and then does a write, so you always have a copy
    Helpful post? Buy me a coffee.
  • #36 20370720
    nielspiersma
    Level 9  
    Posts: 60
    Help: 3
    Rate: 20
    I just wanted to follow up on the new flasher. It worked for the T and the N boards I've here for testing purposes.

    Looking for provisioning OpenBeken devices via URL or any other automated procedure

    Looking for provisioning OpenBeken devices via URL or any other automated procedure

    Only the Do firmware write (no) backup is not working, and the log output window is not resizing.

    I did have some issues starting, but it could have been an issue with my USB to Serial adapter. Once reconnected twice flashing went fine.

    Niels
  • #37 20370814
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14611
    Help: 654
    Rate: 12624
    Huh... you are right in both cases!
    I simply forgot to set an anchor and simply forgot to link the button to an action.
    Thank you! I will fix it right away.
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion revolves around provisioning Beken-based smart plugs using automated procedures via URL commands. The user, experienced with Tasmota and HomeAssistant, seeks efficient methods to configure multiple devices quickly. Key commands for setting up PIN roles and channels are shared, along with challenges related to command length limitations in the backlog feature. Solutions are proposed to enhance command handling, including the addition of commands for WiFi and MQTT configuration. The conversation highlights successful testing of commands that streamline the provisioning process, allowing for rapid setup of devices in AP mode. Suggestions for further enhancements, such as triggering HomeAssistant discovery and managing device flags, are also discussed.
Generated by the language model.

FAQ

TL;DR: OpenBeken’s new builds lift the former 128-byte HTTP cap, letting users provision a BK7231 plug in ≈3 minutes end-to-end; “It now makes no difference … if the device is ESP or BEKEN” [Elektroda, nielspiersma, post #20340151] Why it matters: Single-URL onboarding slashes deployment time for fleets of smart plugs.

Quick Facts

• HTTP & “cmnd” buffer now auto-expands beyond 128 bytes [Elektroda, p.kaczmarek2, post #20339711] • Typical smart-plug flash + provision time: 3 min/device [Elektroda, nielspiersma, post #20345395] • OTA Cloud-Cutter success rate: ~90 % (10 % brick tolerance) [Elektroda, nielspiersma, post #20338867] • One-line URL accepts >300 chars after update [Elektroda, nielspiersma, post #20339845] • New GUI UART flasher auto-backs up full firmware (≈2 MB) [Elektroda, p.kaczmarek2, post #20368287]

What is OpenBeken and why swap ESP8266 for BK7231?

OpenBeken is an open-source firmware for Beken BK7231T/N Wi-Fi SoCs. Tuya adopted BK chips because they cost less than ESP8266 while matching 2.4 GHz performance [Elektroda, nielspiersma, post #20338867] Migrating keeps BOM low yet preserves local control via MQTT and Home Assistant.

Which single-line command provisions all pins on a CB2S plug?

Example: backlog SetPinRole 6 LED_n;SetPinChannel 6,1;SetPinRole 7 Btn;SetPinChannel 7,1;SetPinRole 8 Rel;SetPinChannel 8,1;SetPinRole 26 wifiled;SetPinChannel 26,0 [Elektroda, nielspiersma, post #20339845] Replace pin numbers/roles as required.

How was the 128-byte backlog limit removed?

Developers added dynamic malloc; commands longer than 128 chars now allocate extra RAM at runtime, eliminating truncation [Elektroda, p.kaczmarek2, post #20339711]

How do I set Wi-Fi and MQTT in the same URL?

Append commands inside the same backlog: …;SSID1 ssid-iot;Password1 pw;MqttHost broker.ip;MqttUser user;MqttPassword pass [Elektroda, nielspiersma, post #20340062] Spaces become %20 in the URL.

How can I trigger Home Assistant MQTT discovery?

A dedicated command is planned; until merged, send HA discovery manually after MQTT connect, e.g., publish to homeassistant/switch//config [Elektroda, p.kaczmarek2, post #20340101]

How do I detach a button from the relay?

Assign the pin role Btn_ScriptOnly, then use addEventHandler to publish MQTT events. This mirrors Tasmota’s SetOption114 + SwitchMode15 [Elektroda, p.kaczmarek2, post #20347186]

Is there a command for full or partial factory reset?

Use clearConfig followed by restart to wipe all settings (full). Partial reset keeping Wi-Fi is under discussion [Elektroda, p.kaczmarek2, post #20347186]

Can I trigger OTA firmware updates remotely?

Planned. For now flash via HTTP OTA page or the new GUI UART tool, which backs up firmware automatically before writing [Elektroda, p.kaczmarek2, post #20368287]

What causes “CMD_SetPinRole: This role is not known” errors?

Your command string was truncated at 128 bytes pre-patch, splitting ‘SetPinRole’. Update firmware ≥v200 or shorten commands [Elektroda, nielspiersma, post #20339536]

Edge case: what happens if MQTT credentials are wrong?

Device stays online but HA discovery fails, leaving the plug unmanageable until credentials are corrected and it reconnects [device logs, typical MQTT behaviour].

Is hard-coding passwords safe?

Avoid embedding production passwords in URLs; use temporary credentials, then rotate via MQTT once TLS is enabled [OWASP IoT Guidelines].
Generated by the language model.
ADVERTISEMENT