As an enthusiastic user of HomeAssistant and Smart Home solutions in general, I am always into something new. Recently I’ve become acquainted with OpenBeken. Not wholly voluntary, but is a response to the fact that more Smart Home Devices started using BK7231 vs. good-old ESP82xx.
Undoubtedly I like the fact of being able to log in to a device and configure it to my needs. However, from a manageability perspective, you need the ability to mass-configure devices. When looking at phone provisioning and large-scale OS deployments, provisioning is standard. There is no way you can log in to 200 web interfaces and set individual settings.
Luckily for a few weeks, OpenBeken has introduced the “MQTT Group Topic,” which has eased our life tremendously.
Furthermore, the OpenBeken developers are actively adding configuration parameters with the ability to set them (up) using the MQTT “cmnd”. Combined with the “MQTT Group Topic,” I can now quickly configure multiple devices.
So why is this important to us? Well, let me start by using our own office as an example. Everyone knows about the high costs of electricity and the new rules coming from the EU regarding Co2 emissions and taxes. Saving on electricity consumption is directly impacting these costs. In our office, we have ceiling lights. About 25 of them. Each is equipped with 8 led lamps but still consumes around 100 Watts when lit. Multiply that by 25, and you have a whopping 2500 watts. We found that, on average, we only need ten ceiling lights powered on at any given moment is fine. Thus reducing our average usage by more than 50%. All our ceiling lights were connected to standard earthed sockets. Reason enough to buy 30 or so Smart Sockets. Initially, I tested the Woox R6080, and after sacrificing one unit, I got it running with OpenBeken. At about the same time, I successfully managed to get cloud-cutter to work, which made my work even more straightforward. It took away the need to desolder 25 Tuya boards.
I flashed all 34 Smart Plugs in two evenings. So now my real problems have begun. How to configure all these babies in bulk. I wasn’t planning on logging on to each device setting the required settings. So I started playing around with the same commands I used for bulk configuring my Tasmota devices. Unfortunately, not all the commands I needed were implemented at that time. Thanks to the developers, quite some features were added. But things really got up to speed once the MQTT Group Topic was introduced. This made it possible for me to update all 34 plugs in one go. As well as fine-tuning. This is a breeze as I have the same plugs and the same underlying hardware.
Let me show how I’ve done this;
Flash your device and add it to your WiFi network. No pin settings are needed; we will configure all settings from HomeAssistant.
First, I recommend choosing an MQTT Group Topic based on your hardware chip. This will make updating relatively easy and at least somehow prevent you from pushing N setting to T chips and vice versa. Setting up the MQTT Group Topic is done under “Configure MQTT.” Please make sure you set up your username and password correctly so HomeAssistant can “take control.”
To follow up on this, your Beken Device must report its status (regularly) to HomeAssistant. I recommend setting it up with a special Startup command. This is done in the Change Startup command text.
You should add “scheduleHADiscovery 10”
Now reboot your OpenBeken device and check if it shows up in HomeAssistant
We are now ready to configure the device.
Firmware update example.
Now that your device is integrated in HomeAssistent, you might want to update it remotely. Download the latest firmware and store it in a repository accessible via http. This can be a any type of http server. Let us assume your file resides on a local server with IP address 192.168.1.66 and is called fw.rbl. The URL for the update would http://192.168.1.6/fw.rbl. In HomeAssistant create a new script with the following settings;
When you run the script, it will request all OpenBeken devices subscribed to “BK732N” to download new firmware from the web server.
I want to focus on the “topic” and “payload,” as this is where the actual magic happens.
• cmnd instructs sending a command.
• BK7321N is the MQTT (group) Topic. If you want an individual update, use the MQTT Client/device name
• ota_http is the command your want to send. You can use the commands from https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md and from https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands-extended.md I can tell, it is fun to watch 35 devices updating and rebooting. The aforementioned “scheduleHADiscovery” warrants that your HomeAssistant information is updated. When a new IP address is given or the firmware version changes, this is correctly displayed in HomeAssistant. So you can keep track of the firmware versions and see which devices are not up to date.
Another example is setting the Flags. Sometimes is handy to have flags set. For instance, I like flag 6 being set. This makes sure all relays are triggered instantly. I also have the desire setting flag 10. Setting both flags will give us a flag value of 1088.
Again, we will create a script that updates the flag settings.
Again small breakdown:
• cmnd instructs sending a command.
• bekens is the MQTT (group) Topic.
• flags the command we want to send
• payload 1088 in the case representing Flag 6 and Flag 10
Run the script and all your devices in the MQTT Group “bekens” will get these injected.
We can also setup the device using the backlog command. This allows us to send multiple commands to a device. Quite handy for setting up the configuration.
For example, setting up the Action LSC Smart Plugs
Pins are empty:
The device has Wifi set up, has MQTT Group setup, has scheduleHADiscovery set as startup command, and the device has MQTT host, user, and password setup.
Now configure all pins.
o service: mqtt.publish
o topic: cmnd/obkBF518BE1/backlog
o payload: 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
Run the script and:
This shows the power of the MQTT Group Topic and the way the OpenBeken developers have come making provisioning a breeze. I am quite sure any future command or setting will be addressable via a MQTT cmnd command.
You can also play around with HomeAssistant templates, giving you even more power on the commands you want to execute.
I hope you enjoyed this write up on provisioning on OpenBeken.
Very good writeup. It will be certainly useful for people, even I can learn new interesting things from that.
I will just add here two more notes.
1. If you need anything else (a command, a feature, or a bufix) - message me, I will try to help.
2. OpenBeken, as you may probably know, supports BK7231T, BK7231N, BL602, W800/W801, W600/W601, XR809, T34 and... and Windows Yes, you read right - you can run OpenBeken on Windows, along with IoT device simulator/schematic draw tool and full MQTT support:
What this mean for end user, you may ask? Well, it means that soon you will be able to test all MQTT stuff, all scripting, automation, etc, without even having an IoT device! Just Home Assistant Virtual Machine + OBK simulator will suffice. OBK simulator will be released soon, no binary is yet available.
Being able to run OBK on Windows also speeds up development process a lot.
PS: In a meantime, I have also added a LFS_* commands for writing files to our LittleFS file system.
Please try debugging the issue to determine where exactly is your point of failure.
1. Please try to broadcast a "POWER toggle" command using the same method and topic from HA and check if it works
2. Please try using the OTA command with your URL directly into OBK Web app console and see what happens
When diagnosing a problem, it's always good to check your process step by step and determine where exactly things starts to go wrong.
Btw: windows simulator almost ready, with full MQTT support.