Exemple #1
0
def checkBatteryLevel():
    if (pico_status.bat_level() < minBatteryLevel):
        return "LOW"
    else:
        return "OK"
Exemple #2
0
def checkBatteryLevel():
  if (pico_status.bat_level() < minBatteryLevel):
    return "LOW"
  else:
    return "OK"
Exemple #3
0
                    mailMessage("CRIT")
                    os.system(
                        "/sbin/shutdown -h +% 'UPS Battery Low. Shutting down.'"
                        % shutdownDelay)

        elif (pwrmode == "ONLINE"):
            # Running On line
            online += 1
            onbatt = 0
            if (online == 2):
                # Same state for 5 seconds or more
                print pwrmode
                mailMessage("ONLINE")
            elif (online > 2):
                # Check that battery is charging and UPS is alive
                battV = pico_status.bat_level()
                if (battV < minBattV):
                    minBattV = battV
                if (battV > maxBattV):
                    maxBattV = battV
                if (online == 102):
                    # On the 102th cycle (5mins) maxBattV should be greater than minBattV if charging
                    if ((maxBattV <= minBattV) and (minBattV < 4.1)):
                        mailMessage("BATNOCHARGE")
                # Count 3 to 102 (100 cycles) to check V over one minute
                if (online > 101):
                    online = 3

    # Setup an if loop to run a shutdown command when button press sensed
    if (GPIO.input(27) == 0):
        mailMessage("SHUTDOWN")
Exemple #4
0
          if (checkBatteryLevel()=="LOW"):
            # Report and shutdown
            mailMessage("CRIT")
    	    os.system("/sbin/shutdown -h +% 'UPS Battery Low. Shutting down.'" % shutdownDelay)

      elif(pwrmode=="ONLINE"):
        # Running On line
        online+=1
        onbatt=0
        if (online == 2):
          # Same state for 5 seconds or more
          print pwrmode
          mailMessage("ONLINE")
        elif (online > 2):
          # Check that battery is charging and UPS is alive
          battV=pico_status.bat_level()
          if (battV < minBattV):
            minBattV=battV
          if (battV > maxBattV):
            maxBattV=battV
          if (online == 102):
            # On the 102th cycle (5mins) maxBattV should be greater than minBattV if charging
            if ((maxBattV <= minBattV) and (minBattV < 4.1)):
              mailMessage("BATNOCHARGE")
          # Count 3 to 102 (100 cycles) to check V over one minute
          if (online > 101):
            online = 3
    
    # Setup an if loop to run a shutdown command when button press sensed
    if(GPIO.input(27)==0): 
      mailMessage("SHUTDOWN")