logo elektroda
logo elektroda
X
logo elektroda

[Solved] OpenBeken - How to turn off relay after 1-2 seconds; autoexec.bat script example/change handler

kinziulisKinziulisLT 996 2
ADVERTISEMENT
  • #1 20559874
    kinziulisKinziulisLT
    Level 5  
    ElektrodaBot
    How to make it so that after switching on the status relay, it would be 2 seconds, and then turn off?
  • ADVERTISEMENT
  • Helpful post
    #2 20560056
    p.kaczmarek2
    Moderator Smart Home
    @kinziulisKinziulisLT that bot has the knowledge of ChatGPT, so it's up to 2021. OpenBeken did not exist at that time.

    And to answer your question:
    
    // This will automatically turn off relay after about 2 seconds
    // NOTE: addRepeatingEvent [RepeatTime] [RepeatCount]
    addChangeHandler Channel0 != 0 addRepeatingEvent 2 1 setChannel 0 0
    

    Assuming that your relay is on channel 0, and setting channel 0 to 1 enables relay, then this code will turn off relay always 2 seconds after turning it on.

    Let me know if you need anything more. The following script will always make relay go off after 2 seconds.

    If you want to do something else, for example invoke it from MQTT, then you can do:
    
    alias My_Relay_Cycle backlog setChannel 0 1;  addRepeatingEvent 2 1 setChannel 0 0
    

    and then you can use command My_Relay_Cycle, for example from MQTT cmnd topic.
    Then that command will set channel 0 to 1 (relay on), wait 2 seconds, and set channel 0 to off.
    Helpful post? Buy me a coffee.
  • #3 20560105
    kinziulisKinziulisLT
    Level 5  
    create autoexe.bat

    addChangeHandler Channel1 != 0 addRepeatingEvent 1 1 setChannel 1 0
    addChangeHandler Channel2 != 0 addRepeatingEvent 1 1 setChannel 2 0
    addChangeHandler Channel3 != 0 addRepeatingEvent 1 1 setChannel 3 0
    addChangeHandler Channel4 != 0 addRepeatingEvent 1 1 setChannel 4 0
ADVERTISEMENT