logo elektroda
logo elektroda
X
logo elektroda

Increase watt meter only if the consumption exceeds some value

velovnya 723 6
ADVERTISEMENT
  • #1 20606895
    velovnya
    Level 2  
    Hello! I want to configure the smart plug so that it only adds consumption to the total watt counter only if the consumption exceeds some value. Chipset BK7231N. Firmware OpenBK 1.17.131. Please tell me how to do it? Sorry for my bad English :)
  • ADVERTISEMENT
  • #2 20607494
    p.kaczmarek2
    Moderator Smart Home
    Hello, why do you want to make such a change?
    It would require a little modification in code, but anyone can do it with some basic programming knowledge. You would need to fork our repo, add a single if statement, and let online build get you latest binaries with your change included.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20607581
    velovnya
    Level 2  
    When I charge a battery for a screwdriver, or a battery for a scooter, I then want to see how much energy this battery can now take. I have efficiency factors for my chargers. But when the charging is over in a couple of hours, then the rest of the night or maybe a few days the charging is idle and spoils the statistics. Therefore, for example, if there were some kind of threshold to cut off the idle mode, it would be convenient.

    Added after 19 [minutes]:

    I seem to have found the perfect solution. It turns out that you can write your own scripts and put them in the autoexec. I just wrote a script that turns off the socket if the consumption falls below the threshold.

    
    setChannel 11 0
    
    start1:
     delay_s 5
     if $CH11>=5 then goto end1
     if $power>=60 then goto end2
     if $power<60 then goto end3
    goto start1
    
    end1:
     setChannel 11 0
     setChannel 1 0
     goto start1
    
    end2:
     setChannel 11 0
     goto start1
    
    end3:
     addChannel 11 1
     goto start1
    
  • ADVERTISEMENT
  • Helpful post
    #4 20608217
    p.kaczmarek2
    Moderator Smart Home
    This is a good solution, but it could be written in more efficient manner. Here are some examples:
    
    addChangeHandler Current > 100 setChannel 0 0
    addChangeHandler Power > 40 setChannel 1 0
    addChangeHandler Channel0 < 50 echo value is low
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20608335
    velovnya
    Level 2  
    Wow! So simple! Thank you!
  • #6 20609877
    velovnya
    Level 2  
    Please tell me how to get the value of the energy counter in the script?
  • Helpful post
    #7 20610428
    p.kaczmarek2
    Moderator Smart Home
    Hello, you need to update the firmare, then you can use both on change event and a variable access.
    
    addChangeHandler Energy > 40 setChannel 1 0
    

    
    SendGet http://192.168.0.112/myLogger.php?energy=$energy
    
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around configuring a smart plug with a BK7231N chipset and OpenBK firmware (version 1.17.131) to only add to the total watt counter when power consumption exceeds a specified threshold. The user initially seeks advice on implementing this feature. Responses suggest that a code modification is necessary, specifically adding an if statement to the firmware. The user later discovers a solution by writing a script that disables the socket when consumption falls below a set threshold. Additional suggestions for more efficient scripting are provided, along with guidance on accessing energy counter values through firmware updates and event handling.
Summary generated by the language model.
ADVERTISEMENT