Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5065

Python • Re: UPS Shutdown Python Script

$
0
0
Do you just want to wait 10s instead of 1s before shutdown?
If yes, memjr's suggestions will do the trick.

If however you want to skip the shutdown if the power returns before 10 seconds elapse, then I think this change will do that (I'm assuming pld_state indicates battery vs. AC power).

Code:

     while True:        pld_state = pld_line.get_value()        if pld_state == 1: # AC power            pass        else: # pld_state Not equal to 1            time.sleep(10)            pld_state = pld_line.get_value()            if pld_state != 1: # still Not AC Power                call("sudo nohup shutdown -h now", shell=True)  #uncomment to implement shutdown when power outage

Thank you so much! This does what I need!

Statistics: Posted by DocServo — Thu Jun 13, 2024 1:07 am



Viewing all articles
Browse latest Browse all 5065

Trending Articles