logo elektroda
logo elektroda
X
logo elektroda

OpenBeken on GHome SW6 3-Way Switch (BF7231N): Pinout, LED, Load Detection

akosschneemaier 1020 12
ADVERTISEMENT
  • #1 21538151
    akosschneemaier
    Level 7  
    Hello,

    i just installed OpenBeken on a GHome SW6 3-Way switch with BF7231N chip.

    Here are some pictures:
    Front: White smart light switch with WiFi icon and three wires coming out from the back. Back: Back view of a smart 3-way light switch with labeled wire connections and technical information.

    Config after flashing:
    - Green LED will iluminate when the load is on and >10W
    - Red LED will illuminate when the load is off

    {
    ....
      "pins": {
        "6": "Rel_n;1", - Relay
        "14": "LED;2", - Red LED
        "22": "Btn;1", - Button
        "24": "dInput_NoPullUp_n;2", - Load detector input, low when load is >~10W
        "26": "LED_n;2" - Green LED
      },
    ....
    }
    


    Internals:
    A printed circuit board of an electronic device inside a plastic case with a metal mounting bracket.
    BK7231N chip:
    Electronic module with integrated circuit on a PCB inside a plastic enclosure.

    Serial:
    Close-up of a circuit board with a relay, capacitors, and connected wires.

    And the question:
    Tasmota has a config for the ESP8266 version: See https://templates.blakadder.com/gosund_SW6.html , it has some rules to make the operation more streamlined. I need some help on how to create similar rules under OpenBeken, so on/off/toggle command work nicelly. Can somebody help converting the Tasmota rules to OpenBeken?

    Thanks
  • ADVERTISEMENT
  • #3 21544903
    p.kaczmarek2
    Moderator Smart Home
    How exactly would you like to connect it? Do you pair it with a non-smart switch, or are there two smart switches? With two smart switches, you could use OBK Tasmota Device Groups support.

    Or do you want to integrate the read of dInput_NoPullUp_n to show on/off correctly?
    Helpful post? Buy me a coffee.
  • #4 21545106
    akosschneemaier
    Level 7  
    >>21544903 It is paired with a non-smart switch. I want to make it work the same way as the tasmota version works, so I can send on/off/toggle commands and read on/off status correctly

    Tasmota does this with 3 rules and some dummy components:
    Components
    
    Relay1   A dummy component that stores the power state of the switch.
    Relay2   The actual hardware switch. This controls the state of the circuit (on/off) but, is not a direct indication of the state of the circuit. The relay could be on while the circuit is open.
    Relay3   A dummy component used to process external commands. This is necessary to allow explicit control of the state of the circuit. It should always be in the same state as Relay 1.
    Switch1   The status of the circuit. Switch1’s state will change when the circuit changes. As an example say relay2 is off, the circuit is closed, and Switch1’s state will be 1. If relay2 is toggled to on the, circuit will open and Switch1’s state will change to 0.
    Switch2   The push button on the smart switch. Using Switch instead of button seems to provide a quicker response.
    

    Rules
    
    Backlog Rule1 ON Power3#State do Power2 2 endon ON switch2#state=3 DO publish stat/tasmota_XXXXX/SWITCH1T {"TRIG":"HOLD"} ENDON; Rule1 1
    Rule2 ON Power1#state=0 do Backlog rule1 0; power3 0; rule1 1 endon On Power1#state=1 do Backlog rule1 0; power3 1; rule1 1 endon; Rule2 1
    Backlog Rule3 ON event#OFF do power3 0 endon ON event#ON do power3 1 endon ON event#TOGGLE do power3 2 endon; Rule3 1
    


    I would like to translate the rules to Openbeken, but I am unable to find any useful examples or documentation on rules for Openbeken.

    thanks
  • ADVERTISEMENT
  • #5 21565377
    akosschneemaier
    Level 7  
    After playing around with scripting I ended up with an updated config:
    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Full Device Name Here",
      "model": "enter short model name here",
      "chip": "BK7231N",
      "board": "TODO",
      "flags": "1024",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "6": "Rel_n;2",
        "14": "LED;3",
        "22": "Btn;2",
        "24": "dInput_NoPullUp_n;3",
        "26": "LED_n;3",
        "28": "Rel_n;1"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
    


    And with the following autoexec.bat
    
    alias control_script if $CH1!=$CH3 then ToggleChannel 2
    addEventHandler OnChannelChange 3 SetChannel 1 $CH3 
    addEventHandler OnChannelChange 1 control_script
    
  • ADVERTISEMENT
  • #7 21565621
    p.kaczmarek2
    Moderator Smart Home
    Nice, is it working and fully functional?

    I'm finishing ACL HVAC driver for another user, so if there is a need, I can also make a native (C code) driver for 3-way switch.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #8 21569154
    akosschneemaier
    Level 7  
    >>21565621

    Yes it is working perfectly. Not sure if a driver is needed though
  • #9 21756650
    akosschneemaier
    Level 7  
    @divadiow While I was configuring a new SW6 switch, I realised that Pin 6 should be set to instead of . Can you update the config page: https://openbekeniot.github.io/webapp/devices/GHome_SW6.html

    Also the official template does not mention the event handlers required for correct remote (MQTT) control of the device.

    Thanks.
  • #10 21756721
    divadiow
    Level 37  
    akosschneemaier wrote:
    Can you update the config page


    https://github.com/OpenBekenIOT/webapp/commit/541efe3c31b546d9f28094b59790f8398d22d053

    akosschneemaier wrote:
    Also the official template does not mention the event handlers required for correct remote (MQTT) control of the device


    there isn't the facility in the device list to include the autoexec content required to create a full-functioning device. The user would need to review the linked Elektroda thread to determine any additional requirements. Having said that, some could be expressed as a startup command instead of autoexec.

    Code: Text
    Log in, to see the code


    maybe. don't know off the top of my head if those commands are all valid for startup command though. Are you in a position to test?
  • #11 21757122
    akosschneemaier
    Level 7  
    >>21756721 Thanks! Good points! I am going to test the startup command on the weekend.
  • #12 21760468
    akosschneemaier
    Level 7  
    >>21757122 Tested, and the startup command works for replacing the Autoexec.bat!
  • #13 21760561
    p.kaczmarek2
    Moderator Smart Home
    divadiow wrote:

    there isn't the facility in the device list to include the autoexec content required to create a full-functioning device

    autoexec.bat was created before device list, and then there was idea to just send HTTP GET from OBK to Github to get script:
    https://raw.githubusercontent.com/openshwproj...docs/autoexecs/LED-strip-with-IR-receiver.bat
    But github is HTTPS only and OBK does not have HTTP by default.

    Web App itself maybe could fetch this from a browser and then send to device locally, I need to check

    divadiow wrote:

    Having said that, some could be expressed as a startup command instead of autoexec.

    Code: Text
    Log in, to see the code


    Since some time we have multiline startup command so you can just paste autoexec.bat there I think

    divadiow wrote:

    maybe. don't know off the top of my head if those commands are all valid for startup command though. Are you in a position to test?

    I think both startup command and autoexec.bat should support the same commands, they go through shared implementation
    Helpful post? Buy me a coffee.

Topic summary

The discussion focuses on installing and configuring OpenBeken firmware on a GHome SW6 3-Way switch featuring the BK7231N chip. The user shares pinout details and LED behavior: the green LED indicates load presence above 10W, while the red LED signals load off. The configuration maps pins for relay control, LEDs, button input, and load detection using a "dInput_NoPullUp_n" input. The switch is paired with a non-smart switch, aiming to replicate Tasmota firmware functionality, which uses multiple dummy components and rules to manage relay states and accurately reflect circuit on/off status. An updated JSON configuration and autoexec.bat script are provided to handle channel toggling and state synchronization. Additional responses include sharing original firmware, boot logs, and offers to develop native C drivers for 3-way switch support. The discussion highlights integration challenges of load detection and state reporting in custom firmware for BK7231N-based smart switches.
Summary generated by the language model.
ADVERTISEMENT