Skip to content

Python script that powers down Raspberry Pi & Hubitat when UPS battery drops below threshold.

Notifications You must be signed in to change notification settings

K-MTG/ups_shutdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

ups_shutdown

Python script that powers down Raspberry Pi & Hubitat when UPS battery drops below threshold.

Features

  • Email Alert if UPS is on battery power
  • If UPS battery drops below specified threshold an email alert will be sent out and the Hubitat Hub and Pi will shutdown gracefully.

Installation

  1. Install NUT (Network UPS Tool) on RPI
  2. Install nut2 on Pi (pip3 install nut2)

Usage

On the ups_monitor.py file

  • set the "ip" variable to the IP of your Hubitat Hub
  • set the "username" & "password" to your Hubitat accordingly
  • You can optionally provide gmail login credentials to send an email alert if an outage or shutdown occurs. Modify the "user" and "pwd" variable accordingly. If you do not want email alerts, comment out all calls to "send_email"
  • RUN SCRIPT: python3 ups_monitor.py (add this to crontab -e on @reboot if you want the script to autostart on bootup).

The "UPS_SHUTDOWN_THRES" variable is the percent at which the Pi and Hubitat will shutdown. THE "UPS_SHUTDOWN_MIN_THRES" is the number of minutes remaining on the UPS when the Pi and Hubitat will shutdown Note: The shutdown will occur if either the UPS_SHUTDOWN_THRES or UPS_SHUTDOWN_MIN_THRES conditions are satisfied. The "CHECK_INTERVAL" is the number of seconds on how frequently the script checks the UPS status.

About

Python script that powers down Raspberry Pi & Hubitat when UPS battery drops below threshold.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages