logo elektroda
logo elektroda
X
logo elektroda

[Solved] [OpenBeken] Switching on the relay for 15 minutes, every 60 minutes.

skyvladik 1176 7
ADVERTISEMENT
  • #1 20429060
    skyvladik
    Level 4  
    Hello. Please tell me how to implement switching on the relay for 15 minutes, every 60 minutes. LSPA9 smart socket, WB2S chip.

    Added after 10 [minutes]:

    LSPA9 WB2S
    P6 (PWM0) WifiLED_n
    P7 (PWM1) BL0937CF
    P8 (PWM2) BL0937CF1
    P10 (RXD1) Btn
    P24 (PWM4) BL0937SEL
    P26 (PWM5) Rel
    Configure module.
  • ADVERTISEMENT
  • Helpful post
    #2 20429621
    p.kaczmarek2
    Moderator Smart Home
    Hello, addRepeatingEvent should work for that;
    Do you know how to create autoexec.bat in LittleFS in Web Application?

    15 minutes is 900 seconds.
    60 minutes is 3600 seconds.

    Repeating event syntax:
    
    addRepeatingEvent [DelaySeconds] [Repeats] [Command With Spaces Allowed]
    

    Repeats can be -1 for infinite repeating

    So maybe something like that? I haven't checked, but the generic idea should be ok.
    
    alias turn_on_and_off backlog POWER 1; addRepeatingEvent 900 1 POWER 0
    addRepeatingEvent 3600 -1 turn_on_and_off
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20430371
    skyvladik
    Level 4  
    Hello. Thanks for the reply. I learned how to create an autoexec.bat file. I took advantage of your idea. It works. But there is one thing, the relay switches only the first time. The next time the relay clicks quieter and quieter, even the LED does not light up. But if you use power 1 and power 0 via the command line, then everything works. It seems to me that the whole point is in the addChangeHandler command, this leads to increased current consumption by the WB2S chip. Sometimes I even watched the chip reboot. Pressing the physical button also led to a reboot of the chip. Perhaps the problem is in a weak power supply, but it is necessary to disassemble the smart socket. Is another implementation of these switches possible, is it not possible to use time binding. Thank you for reading this.
  • Helpful post
    #4 20430401
    p.kaczmarek2
    Moderator Smart Home
    The repeating event is only adding execution of a simple loop, there is not much calculations done, what kind of device do you have?

    I have tested it right now on LSPA9 and it seems to work? But with 10 and 5 second delay. I am going for a walk, I will leave it running and check when I come back.

    You can try adding "PowerSave" command to autoexec (it must be executed once every reboot to enter low power mode).

    Please let me know if PowerSave works for you and what kind of device you have. Do you have anything else running? DGR? SSDP?

    EDIT: my code works for me, maybe you entered it several times and have multiple Repeating Events running and colliding with each other? or made a typo

    EDIT2: The thing that can increase power usage and "tire" device is keeping web app log open forever, because it does HTTP packets every few second and sends lots of data
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20430484
    skyvladik
    Level 4  
    Content autoexec.bat:
    PowerSave;
    backlog POWER 1; addRepeatingEvent 5 -1 POWER 0; addRepeatingEvent 10 -1 POWER 1

    I closed all the web pages of the module, but still the relay clicks quietly, the module reboots after a while.
  • Helpful post
    #6 20430513
    p.kaczmarek2
    Moderator Smart Home
    skyvladik wrote:

    backlog POWER 1; addRepeatingEvent 5 -1 POWER 0; addRepeatingEvent 10 -1 POWER 1

    The following code will try to set POWER 0 every 5 second and also try to set POWER 1 every 10 second. I am not sure right now what is the order of the operations, but you will basically try to set POWER to 0 and to 1 in a single frame. This doesn't seem correct.

    You know what, let me check...
    [OpenBeken] Switching on the relay for 15 minutes, every 60 minutes.
    yea, that's what I thought. The latter repeaters are added to the start of the linked list.

    So, basically your code does this:
    - wait 5 seconds
    - set power to 0 (caused by addRepeatingEvent 5 -1 POWER 0)
    - wait 5 seconds
    - set power to 1 (caused by addRepeatingEvent 10 -1 POWER 1)
    - set power to 0 (caused by addRepeatingEvent 5 -1 POWER 0)
    and again... and so on.

    This is logically not correct and this cannot work. In your case relay is powered on only for a little fraction of a second, just for a few instruction cycles.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20431818
    skyvladik
    Level 4  
    Thanks for the clarification, I will correct it now. I do not know why your option did not work initially. I have made your version work, thank you. I am losing the connection probably due to a poor Wi-Fi level, because the flashing of the blue LED is sometimes observed now. This is a temporary location of the outlet, in the future it will be located elsewhere. Thanks for the help.
  • #8 20442975
    skyvladik
    Level 4  
    alias turn_on_and_off backlog POWER 1; addRepeatingEvent 900 1 POWER 0
    addRepeatingEvent 3600 -1 turn_on_and_off

Topic summary

The discussion revolves around implementing a relay control for the LSPA9 smart socket using the WB2S chip, specifically to switch on the relay for 15 minutes every 60 minutes. Initial suggestions included using the `addRepeatingEvent` command to schedule the relay operations. However, issues arose with the relay only functioning correctly the first time, followed by diminished performance and occasional reboots of the WB2S chip, potentially due to power supply issues. Users explored various configurations in the `autoexec.bat` file, including commands to manage power states and reduce current consumption. Ultimately, a working solution was achieved, but concerns about Wi-Fi connectivity affecting performance were noted.
Summary generated by the language model.
ADVERTISEMENT