basic support for pushsafer.com

Currently, only a message with the link to the pi.alert page is sent. I am still struggling with the display of more detailed information.
This commit is contained in:
leiweibau
2022-07-20 21:21:21 +02:00
parent 338d163fd4
commit 1928d1b581
2 changed files with 32 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ import socket
import io
import smtplib
import csv
from urllib.parse import urlencode
from urllib.request import Request, urlopen
#===============================================================================
@@ -1359,6 +1361,11 @@ def email_reporting ():
print (' Skip mail...')
else :
print (' No changes to report...')
if REPORT_PUSHSAFER :
print (' Sending report by PUSHSAFER...')
send_pushsafer (mail_text)
else :
print (' Skip PUSHSAFER...')
# Clean Pending Alert Events
@@ -1376,6 +1383,27 @@ def email_reporting ():
sql_connection.commit()
closeDB()
#-------------------------------------------------------------------------------
def send_pushsafer (_Text):
url = 'https://www.pushsafer.com/api'
post_fields = {
"t" : 'Pi.Alert Message',
"m" : 'Something has changed',
"s" : 11,
"v" : 3,
"i" : 148,
"c" : '#ef7f7f',
"d" : 'a',
"u" : REPORT_DASHBOARD_URL,
"ut" : 'Open Pi.Alert',
"k" : PUSHSAFER_TOKEN,
}
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
# print(json)
#-------------------------------------------------------------------------------
def format_report_section (pActive, pSection, pTable, pText, pHTML):
global mail_text

View File

@@ -23,6 +23,10 @@ REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>'
REPORT_TO = 'user@gmail.com'
REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac='
REPORT_PUSHSAFER = False
REPORT_DASHBOARD_URL = ''
PUSHSAFER_TOKEN = 'ApiKey'
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'
DDNS_ACTIVE = False