logo elektroda
logo elektroda
X
logo elektroda

Preventing Simultaneous Activation of Both Relays in OpenBK7231T-Tuya Shutter Switch

hoezyhoest 1806 11
ADVERTISEMENT
  • #1 20413815
    hoezyhoest
    Level 2  
    I just flashed my tuya shutter switch with openbk7231t and everything is working correctly. but how can I prevent activating both relays at the same time? I need something like the shutter mode in tasmota. or is my only option to replace the WB3S chip with ESP and flash tasmota on it?
  • ADVERTISEMENT
  • #2 20413848
    p.kaczmarek2
    Moderator Smart Home
    Well, I can write any driver for you if you want, but it should be also possible to both configure or script OBK to suit your needs.

    You could, for example, set one relay Rel and second to Rel_n, and set them both to single channel, then they would work in mutually exclusive way.

    You could also use some scripting - for example, make a change handler and do something there:
    
    addChangeHandler Channel0 == 1 YourCommandHere
    addChangeHandler Channel0 == 0 YourCommandHere
    

    You can use any command in event handler, or even start a script.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    You can also use repeating event with counter set to 1 to do something after a delay.
    
    addRepeatingEvent 2 1 setChannel 0 0
    


    but again, if you have a specific use case in mind, I can write a dedicated driver for you, as long as you can explain how is it supposed to work. Show your device configuration, etc.
    Helpful post? Buy me a coffee.
  • #3 20414102
    hoezyhoest
    Level 2  
    i tried setting them both to single channel but it still keeps one of them constantly on.
    i tried the scripting part but that is a bit complicated for me :P (i do know how to run them)

    i'm using a switch like this and i need something like the InterLock setting in tasmota so that none can accidentally fire two relays on the physical touch buttons
    https://templates.blakadder.com/WF-CS01_EU.html

    these are my settings:

    Preventing Simultaneous Activation of Both Relays in OpenBK7231T-Tuya Shutter Switch
  • #4 20414125
    p.kaczmarek2
    Moderator Smart Home
    I am not sure yet, but just maybe, this autoexec.bat (in Web Application ->LittleFS tab) can help?
    
    // when channel 0 becomes 1, turn off channel 1
    addChangeHandler Channel0 == 1 SetChannel 1 0
    // when channel 1 becomes 1, turn off channel 0
    addChangeHandler Channel1 == 1 SetChannel 0 0
    

    I haven't done shutters yet. Futhermore, do they require turning off both relays after a given time?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20414151
    hoezyhoest
    Level 2  
    thnx alot! this is the same as the interlock from tasmota and works like a charm :)

    i'm using home assistant to time the relays so that's not a problem. this was only for protection so i won't blow up the motors by accident.


    cheers!
  • ADVERTISEMENT
  • Helpful post
    #6 20433363
    maliciamrg
    Level 2  
    hello ,

    Thks to you two i have complet the setting of my shutter switch WF-CS01_EU

    in complement of your setting , i post mine (5 leds , 3 buttons and 2 relai) :

    Preventing Simultaneous Activation of Both Relays in OpenBK7231T-Tuya Shutter Switch

    and like sugest p.kaczmarek2 , i add a autoexec.bat file , who mimic the original firmware :

    
    //blue led on
    SetStartValue 3 1
    
    // interlock relais
    addChangeHandler Channel0 == 1 SetChannel 2 0
    addChangeHandler Channel2 == 1 SetChannel 0 0
    
    //cancel button
    addChangeHandler Channel1 == 1 SetChannel 0 0
    addChangeHandler Channel1 == 1 SetChannel 2 0
    
    //toggle night led mode
    addEventHandler OnHold 10 ToggleChannel 3
    
    //auto cancel relais after delai 34s
    addChangeHandler Channel0 == 1 addRepeatingEventID 34 1 910 SetChannel 0 0
    addChangeHandler Channel2 == 1 addRepeatingEventID 34 1 912 SetChannel 2 0
    
    //auto cancel cancel button after 5s
    addChangeHandler Channel1 == 1 addRepeatingEventID 5 1 911 SetChannel 1 0
    
    //auto cancel cancel relai
    addChangeHandler Channel1 == 1 cancelRepeatingEvent 910
    addChangeHandler Channel1 == 1 cancelRepeatingEvent 912
    


    :spoko:
  • ADVERTISEMENT
  • #7 20433374
    p.kaczmarek2
    Moderator Smart Home
    So you've made a shutters support entirely in our scripting language? Nice.

    I've been also prototyping something like that, here:
    https://github.com/openshwprojects/OpenBK7231...rc/selftest/selftest_demo_scriptForShutters.c
    Helpful post? Buy me a coffee.
  • #8 20433399
    maliciamrg
    Level 2  
    p.kaczmarek2 wrote:
    So you've made a shutters support entirely in our scripting language? Nice.

    I've been also prototyping something like that, here:
    https://github.com/openshwprojects/OpenBK7231...rc/selftest/selftest_demo_scriptForShutters.c


    Wow, now I know how to use "alias" and "backlog", pretty powerful.

    If I can suggest a use case to add in your demo, the possible mind changing of a user. (aka: I start to open my shutter but at the mid course I change my mind and decide to close it)

    Thanks for your work for developing this firmware which saves a lot of my wifi OT, you rock.
  • #9 20433581
    p.kaczmarek2
    Moderator Smart Home
    Your script seems pretty nice, you could submit it as another demo/self test (in separate file) via pull request
    Helpful post? Buy me a coffee.
  • #10 21587087
    spleefer90
    Level 7  
    I also need this, and the scripting works, but it triggers the relay before deactivating the second one.

    This happens near instantly, but it still means both are on for a split second, does it not?

    I cannot use the Rel Rel_n on the same channel, as I have two relays controlling my electric roller blinds going up or down.

    I want to either send UP with rel1, or DOWN with rel2, or neither when idle.
    I do not want to send them either an ON or OFF signal at all times, I want to send no signals when idle (both relays off).
    I do not want them to ever be ON and OFF at the same time (already fried one relay).

    The handler setchannel is my current solution for the time being, but I do hope I can hook something to turn the relay on another channel OFF before turning one ON.

    EDIT: This code seems to not be enough, seems like the split moment is enough to break my relay and invert it, broke another one. I think I want a small delay of OFF on both relays before one triggers on, but I am lost as to how to do this on OBK.
  • #11 21594298
    p.kaczmarek2
    Moderator Smart Home
    I'm working on alternate solution for that - ability to link two pins to single channel and use 3 channel values for disabled, up or down.
    Currently working self-test code:
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.

Topic summary

The discussion addresses preventing simultaneous activation of both relays in a Tuya shutter switch flashed with OpenBK7231T firmware. The main concern is to avoid damaging the motor by ensuring only one relay is active at a time, similar to the "shutter mode" or "InterLock" feature in Tasmota firmware. Solutions include configuring relays as single channels with mutual exclusivity or using scripting with event handlers (addChangeHandler) to turn one relay off when the other is activated. An example script in autoexec.bat uses change handlers to enforce interlock behavior by switching off the opposite relay upon activation. Users also shared more complex scripts mimicking original firmware behavior, including auto-cancel timers and button handling. Challenges remain with the brief overlap when switching relays, which can cause hardware damage; a proposed solution involves implementing a delay (dead time) between turning one relay off and the other on, with ongoing development of a PinMutex driver to manage this safely. The discussion includes references to scripting capabilities, demo scripts for shutter control, and integration with Home Assistant for timing relay deactivation.
Summary generated by the language model.
ADVERTISEMENT