Skip to content

Instantly share code, notes, and snippets.

@gsemet
Last active May 31, 2017 07:50
Show Gist options
  • Save gsemet/a170111772e262522e5515439faf5581 to your computer and use it in GitHub Desktop.
Save gsemet/a170111772e262522e5515439faf5581 to your computer and use it in GitHub Desktop.
NUT notification to PushOver
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
from pushover import init
from pushover import Client
USER_KEY = "xxxxxxxxxxxxxxxx"
APP_TOKEN = "xxxxxxxxxxxxxxxx"
message = ''
if len(sys.argv) > 1:
message = sys.argv[1].strip()
notify_type = os.environ.get('NOTIFYTYPE', "")
if notify_type == "ONBATT":
message = "Connected UPS has entered battery mode"
elif notify_type == "ONLINE":
message = "Connected UPS has returned to AC mode"
elif not message:
message = "(no message)"
init(APP_TOKEN)
print("Sending message: " + message)
Client(USER_KEY).send_message(message, title="Server Name")
# Test with upsdrvctl -t shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment