logo elektroda
logo elektroda
X
logo elektroda

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

akosschneemaier 1515 12
Best answers

How can I convert the Tasmota rules for a GHome SW6 3-way BK7231N switch into OpenBeken so on/off/toggle commands and correct status reporting work properly?

Use an OpenBeken channel mapping where the hardware relay is on channel 2, the external switch state is mirrored to channel 1, and channel 3 is used for remote control/state syncing; one working setup uses pin 6 as `Rel`/relay, pins 14 and 26 for the red/green LEDs, pin 22 for the button, and pin 24 as `dInput_NoPullUp_n` for the load detector, with the later correction that pin 6 should be `Rel` rather than `Rel_n` [#21565377][#21756650] The working script is: `alias control_script if $CH1!=$CH3 then ToggleChannel 2`; `addEventHandler OnChannelChange 3 SetChannel 1 $CH3`; `addEventHandler OnChannelChange 1 control_script` [#21565377] This makes channel 1 track the actual switch/load state, channel 3 accept explicit ON/OFF/TOGGLE commands, and channel 2 drive the hardware relay [#21565377] For remote MQTT control, the same multiline commands can be put into the Startup Command, because it works as a replacement for `autoexec.bat` [#21756721][#21760468][#21760561] The device was confirmed to work perfectly with this approach [#21569154]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • OpenBeken pinout and load-detect mapping for GHome SW6

    #1 21538151
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    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
  • #2 21538835
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    Adding the original firmware downloaded from the device.

    Edit: updated the attached firmware
    Attachments:
    • GHomeSW6.20250505.bin (2 MB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #3 21544903
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    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.
  • ADVERTISEMENT
  • Need OpenBeken rules for dummy relay state handling

    #4 21545106
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    >>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
  • Updated OpenBeken config and channel sync script

    #5 21565377
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    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
    
  • Boot log confirms BK7231N firmware initialization

    #6 21565391
    divadiow
    Level 38  
    Posts: 5188
    Help: 445
    Rate: 912
    https://github.com/OpenBekenIOT/webapp/pull/192

    also, boot log:
    Code: Text
    Log in, to see the code


    added to https://github.com/openshwprojects/FlashDumps as GHome_SW6_(SW6楼梯开关-SchemaID-dwfc3c)_oeytjppolzogtwfb_Z2-N-V1.1_1.1.3.bin

    device is patched against Cloudcutter exploit
  • ADVERTISEMENT
  • #7 21565621
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    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.
  • #8 21569154
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    >>21565621

    Yes it is working perfectly. Not sure if a driver is needed though
  • #9 21756650
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    @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.
  • Need to add MQTT event handlers to template

    #10 21756721
    divadiow
    Level 38  
    Posts: 5188
    Help: 445
    Rate: 912
    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  
    Posts: 18
    Rate: 6
    >>21756721 Thanks! Good points! I am going to test the startup command on the weekend.
  • #12 21760468
    akosschneemaier
    Level 7  
    Posts: 18
    Rate: 6
    >>21757122 Tested, and the startup command works for replacing the Autoexec.bat!
  • Startup command may replace autoexec.bat

    #13 21760561
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    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

✨ Discussion about flashing OpenBeken on a GHome SW6 3-way wall switch based on the BK7231N/BF7231N platform. The initial pin mapping included relay, red LED, green LED, button, and a load-detection input that indicates when the connected load is above about 10 W. The thread then focused on how to make the device behave like the Tasmota 3-way implementation when paired with a non-smart switch, including correct on/off/toggle control and accurate status reporting from the load-detect input. After scripting experiments, an updated configuration and autoexec logic were created using channel event handlers to synchronize the dummy state channel with the hardware relay channel. Later corrections noted that pin 6 should be configured as Rel instead of Rel_n, and that the official device template should include the required startup/event-handler commands for full MQTT remote control. The startup command was confirmed to work as a replacement for autoexec.bat.
AI summary based on the discussion. May contain errors.

FAQ

TL;DR: GHome SW6 on OpenBeken works with a ~10 W load-detect threshold; “Green LED will illuminate when the load is on and >10W.” Use simple event handlers or a Startup Command for correct MQTT control. [Elektroda, akosschneemaier, post #21538151]

Why it matters: This FAQ shows how to wire, script, and remotely control a BF7231N-based 3‑way switch with reliable state reporting.

Quick Facts

What is OpenBeken in this context?

OpenBeken is the firmware the user flashed onto the GHome SW6 (BF7231N) to replace the stock Tuya firmware and enable custom control, scripting, and MQTT integration. [Elektroda, akosschneemaier, post #21538151]

What is the full working pinout used by the community post?

Example mapping: 6=Rel_n;2 (later corrected to Rel), 14=LED;3 (Red), 22=Btn;2, 24=dInput_NoPullUp_n;3 (load sense), 26=LED_n;3 (Green), 28=Rel_n;1. [Elektroda, akosschneemaier, post #21565377]

How do I get correct MQTT on/off/toggle control and status?

Add event handlers so CH1 mirrors the sensed circuit state (CH3) and the relay channel toggles only when needed. Use: alias control_script if $CH1!=$CH3 then ToggleChannel 2; addEventHandler OnChannelChange 3 SetChannel 1 $CH3; addEventHandler OnChannelChange 1 control_script. [Elektroda, akosschneemaier, post #21565377]

Can I use Startup Command instead of autoexec.bat?

Yes. A single Startup Command string can replace autoexec.bat for this device, and it was tested successfully. “Tested, and the startup command works.” [Elektroda, akosschneemaier, post #21760468]

What Startup Command string was proposed?

Use: backlog powersave 1; alias control_script if $CH1!=$CH3 then ToggleChannel 2; addEventHandler OnChannelChange 3 SetChannel 1 $CH3; addEventHandler OnChannelChange 1 control_script. This sets power save and creates the handlers at boot. [Elektroda, divadiow, post #21756721]

How does load detection work on the SW6?

The dInput_NoPullUp_n line reads LOW when the attached load exceeds approximately 10 W. The Green LED indicates ON above that threshold; Red indicates OFF. [Elektroda, akosschneemaier, post #21538151]

Will this setup work in a real 3‑way with a non‑smart companion?

Yes. The poster uses it with a non‑smart switch and confirms full functionality once the handlers are in place. [Elektroda, akosschneemaier, post #21569154]

Is the SW6 vulnerable to Cloudcutter?

The posted dump notes the device is patched against the Cloudcutter exploit, affecting OTA‑style flashing paths. [Elektroda, divadiow, post #21565391]

Why won’t the device list include my event handlers?

The device list cannot embed autoexec content. Use Startup Command, which the author notes could express needed logic. [Elektroda, divadiow, post #21756721]

Any platform limitations I should know?

OpenBeken cannot fetch HTTPS scripts directly (e.g., raw GitHub). The web app might fetch and push locally as a future workflow. [Elektroda, p.kaczmarek2, post #21760561]

How do I set up the SW6 for a non‑smart 3‑way in three steps?

  1. Assign pins (Btn, LEDs, dInput_NoPullUp_n=load sense, Relay, etc.) in OpenBeken.
  2. Add alias/control_script and two addEventHandler lines to keep CH1 synced and toggle CH2 only when needed.
  3. Reboot and verify button and MQTT on/off/toggle update CH1 correctly. “Works perfectly.” [Elektroda, akosschneemaier, post #21565377]

What does the boot log tell me about the Tuya build?

The shared log shows a Tuya SDK build compiled on Apr 10, 2024, and BLE/Wi‑Fi init details for troubleshooting. [Elektroda, divadiow, post #21565391]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT