Elektroda.com
Elektroda.com
X

How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration

p.kaczmarek2 1245 2
  • How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    Every OpenBeken/Tasmota/etc device requires a brief configuration after the initial flashing of the firmware. This configuration requires setting a proper roles for GPIOs, which are different for each device. Here I will show you an automatic way to configure GPIOs in OpenBeken. In OpenBeken, you can import GPIO directly from Tuya settings. This method is quick and efficient and works for most of the devices, only the TuyaMCU ones might require fully manual work.

    Topic assumption
    This topic assumes you have already flashed OpenBeken to your BK7231/BK7231T/BK7231N/XR809/W600/W800/BL602/other WiFi devices. You can find flashing guides on our youtube channel:
    https://www.youtube.com/watch?v=L6d42IMGhHw&list=PLzbXEc2ebpH0CZDbczAXT94BuSGrd_GoM
    and on our devices list:
    https://openbekeniot.github.io/webapp/devicesList.html

    Where to get templates?
    There are multiple places where you can get device templates.
    First, you can search our detailed teardowns list, here:
    https://openbekeniot.github.io/webapp/devicesList.html
    Here you can use various filters to browse devices list effectively, you can also click device name to get more or less detailed guide and discussion topic open:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    You can also use cloudcutter profiles from here:
    https://github.com/tuya-cloudcutter/tuya-cloudcutter.github.io/tree/master/devices
    We are also working on frontend for cuttable devices here (coming soon):
    https://openbekeniot.github.io/webapp/cutterList.html
    It is also important to mention how are tuya-cloudcutter profiles created. This is for advanced users, but you can create them from 2MB device binary dump taken by our flash tool:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Just use the cloudcutter profile-building tool:
    https://github.com/tuya-cloudcutter/tuya-cloudcutter/tree/main/profile-building
    See readme for more info:
    https://github.com/tuya-cloudcutter/tuya-cloudcutter/blob/main/profile-building/README.md
    That way you can generate user_param_key.json with Tuya json config.
    Special thanks to tuya-cloudcutter contributors for making such useful tool!

    What is inside template?
    This is a technical only section, skip it if you're not interested.
    Here is a sample OpenBeken template:
    Code: json
    Log in, to see the code

    OpenBeken template consists some basic information about the device, device image, device page (discussion) topic, some keywords and a GPIO array. Each GPIO has a role and a channel. Channels are used to group together relays with buttons and to set PWM order for RGB, etc, devices.
    
        "26": "Rel;2"
    

    this means P26 has a Relay on channel (group) 2.
    Here is a tuya-cloudcutter template:
    Code: json
    Log in, to see the code

    There is also some information about the device, a device name, manufacturer, but there are no pins array. Instead, we have a Tuya json called device_configuration, also called user_param_key.
    Let's consider this fragment:
    Code: json
    Log in, to see the code

    The keys with "pin" suffix are pin indexes. For example, you can see that Relay 4 (group 4, in obk called "channel") is on P26 and a button (pairing/toggle all) is on P24.

    Template import page
    Now we assume that you have copied your device JSON profile, either from OpenBeken list (use Copy button) or from Cloudcutter.
    Those profiles are in different format, but can be very easily imported to OpenBeken.
    On OBK device, open Web Application and then Import tab:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    Here you can paste the JSON config. Multiple JSON formats are supported. Please paste to first field (step 1). JSON will be converted to OBK commands in the second column (step 2).
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    You can modify resulting script if you want. For example, you can change commands. Once you are happy, press the big apply script button. Here is a correct import:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    The import field features error detection. It will show an error if pasted JSON is invalid:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    OpenBeken JSON template format also works:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    Both text fields have error checking implemented.
    If you edit command manually and do a typo, you will get a failure during execution:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration

    Even easier template import method
    Don't forget that you can just select device from drop down list on OBK Web Application. There you can also automatically import template, even without doing copy+paste:

    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration

    Template converter public frontend
    We have also released a little frontend for the template importer. It's not recommended to use it, but it's publicly available here:
    https://openbekeniot.github.io/webapp/templateImporter.html

    What if there is no template?
    It is also possible that you get a device that has no template yet, neither in OpenBeken list and not in Tuya-cloudcutter. In this case, you can take multiple approaches:
    - search for similiar devices on our lists and try their configs
    - open device and check with multimeter where traces are going (WiFi module pinouts are here)
    - just use a brute force approach - for example, set first 5 pins to Relay on channel 1, then save config, then try toggling them - do anything happen? If one of your relay toggles, then you know your relay is among those 5 pins. So try to narrow down selection. If not, your relay is on other pin. This also works for PWMs.
    - for LEDs, you can just use approach with relays (relay will just set PWM to 0 or 100%), or you can also enable "show raw LED controls" in OBK flags
    - for LEDs, remember that BK7231 supports PWM only of 6 pins, so for RGBCW (5 PWMs) there is not much choice.
    PWM IO
    PWM0P6
    PWM1P7
    PWM2P8
    PWM3P9
    PWM4P26
    PWM5P24
    - you can always ask for help here, I am here every day to help you!

    What about TuyaMCU devices?
    TuyaMCU devices are using WiFi module for communication with outside world and MCU for processing. The MCU communicates with WiFi module via TuyaMCU protocol. We have a TuyaMCU analyzer tool for this purpose, please refer to topic below:
    https://www.elektroda.com/rtvforum/topic3970199.html


    Summary
    There are multiple ways to import device into OpenBeken.
    You can get a template manually, either from tuya-cloudcutter/device binary, or from OpenBeken templates. OpenBeken templates are better, because they are user-created and usually more complete, but a template from tuya json can be a good quickstart for basic devices. As you can see, there are many ways to get OBK running, but remember, no matter which approach you choose, you can always ask for help on our forum. Have fun!

    Cool? Ranking DIY
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 4850 posts with rating 5183, helped 235 times. Been with us since 2014 year.
  • #2
    DeDaMrAz
    Level 10  
    Just to mention that you need latest OBK build (1.17.29 at the time of writing) for this to work.

    One thing to note if you are importing JSON files, it will purge the autoexec.bat so make sure to back it up if you have it on your device!!

    To do that go to filesystem tab on web app, click List Filesystem and if present click on Download Tar of FS and save it to a known location.
  • #3
    p.kaczmarek2
    Moderator Smart Home
    Very good point. It is, however, also useful to notice that the autogenerated script in second column includes lfs_format command:
    How to import OpenBeken/Cloudcutter templates - automatic GPIO/device configuration
    so, if desired,this command can be just removed before execution.