logo elektroda
logo elektroda
X
logo elektroda

OpenBeken script to turn off relay when power value drops below margin

ferbulous 582 3
ADVERTISEMENT
  • #1 20646273
    ferbulous
    Level 18  
    hi @p.kaczmarek2
    For the scripts, i'm trying to get my plug with power monitoring to turn off charging once it reaches value (below 20 watts for example)
    In tasmota, i could add this rule

    Rule1
       on Energy#Power<20 do RuleTimer1 100 endon 
       on Energy#Power>20 do RuleTimer1 0 endon
    Rule2 
       on Rules#Timer=1 do Power OFF endon
    Rule1 1
    Rule1 5
    Rule2 1


    Rule1 is set to once mode (Rule1 5), so after power drops below 20 watts it only starts once otherwise the timer would keep restarting.
    How can I do this in the script?
  • ADVERTISEMENT
  • #2 20646340
    p.kaczmarek2
    Moderator Smart Home
    I am not sure about your Rules script, but maybe something like that?
    addChangeHandler Power < 20 POWER OFF

    When power changes from equal or above 20, to below 20, it will execute power off.
    This happens only on change, not when Power is kept under 20. If power changes from 5 to 10, it will not fire. It fires only on change like 21 goes to 19, etc.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20648610
    ferbulous
    Level 18  
    p.kaczmarek2 wrote:
    I am not sure about your Rules script, but maybe something like that?
    addChangeHandler Power < 20 POWER OFF

    When power changes from equal or above 20, to below 20, it will execute power off.
    This happens only on change, not when Power is kept under 20. If power changes from 5 to 10, it will not fire. It fires only on change like 21 goes to 19, etc.


    Thanks, I added a timer in tasmota so it only triggers relay off after a few minutes rather than instantly trigger it. Just to ensure the device gets fully charged
  • Helpful post
    #4 20652436
    p.kaczmarek2
    Moderator Smart Home
    You can do the same in OBK by:
    
    // alias to turn off relay after 4 secs (repeating event with 1 repeat)
    addChangeHandler Power < 20 addRepeatingEvent 4 1 POWER OFF
    
    Helpful post? Buy me a coffee.
ADVERTISEMENT