Apprise payload type setting
This commit is contained in:
@@ -275,7 +275,7 @@ def importConfig ():
|
|||||||
# Webhooks
|
# Webhooks
|
||||||
global REPORT_WEBHOOK, WEBHOOK_URL, WEBHOOK_PAYLOAD, WEBHOOK_REQUEST_METHOD
|
global REPORT_WEBHOOK, WEBHOOK_URL, WEBHOOK_PAYLOAD, WEBHOOK_REQUEST_METHOD
|
||||||
# Apprise
|
# Apprise
|
||||||
global REPORT_APPRISE, APPRISE_HOST, APPRISE_URL
|
global REPORT_APPRISE, APPRISE_HOST, APPRISE_URL, APPRISE_PAYLOAD
|
||||||
# NTFY
|
# NTFY
|
||||||
global REPORT_NTFY, NTFY_HOST, NTFY_TOPIC, NTFY_USER, NTFY_PASSWORD
|
global REPORT_NTFY, NTFY_HOST, NTFY_TOPIC, NTFY_USER, NTFY_PASSWORD
|
||||||
# PUSHSAFER
|
# PUSHSAFER
|
||||||
@@ -342,6 +342,7 @@ def importConfig ():
|
|||||||
REPORT_APPRISE = ccd('REPORT_APPRISE', False , c_d, 'Enable Apprise', 'boolean', '', 'Apprise', ['test'])
|
REPORT_APPRISE = ccd('REPORT_APPRISE', False , c_d, 'Enable Apprise', 'boolean', '', 'Apprise', ['test'])
|
||||||
APPRISE_HOST = ccd('APPRISE_HOST', '' , c_d, 'Apprise host URL', 'text', '', 'Apprise')
|
APPRISE_HOST = ccd('APPRISE_HOST', '' , c_d, 'Apprise host URL', 'text', '', 'Apprise')
|
||||||
APPRISE_URL = ccd('APPRISE_URL', '' , c_d, 'Apprise notification URL', 'text', '', 'Apprise')
|
APPRISE_URL = ccd('APPRISE_URL', '' , c_d, 'Apprise notification URL', 'text', '', 'Apprise')
|
||||||
|
APPRISE_PAYLOAD = ccd('APPRISE_PAYLOAD', 'html' , c_d, 'Payload type', 'selecttext', "['html', 'text']", 'Apprise')
|
||||||
|
|
||||||
# NTFY
|
# NTFY
|
||||||
REPORT_NTFY = ccd('REPORT_NTFY', False , c_d, 'Enable NTFY', 'boolean', '', 'NTFY', ['test'])
|
REPORT_NTFY = ccd('REPORT_NTFY', False , c_d, 'Enable NTFY', 'boolean', '', 'NTFY', ['test'])
|
||||||
@@ -451,7 +452,7 @@ last_internet_IP_scan = now_minus_24h
|
|||||||
last_API_update = now_minus_24h
|
last_API_update = now_minus_24h
|
||||||
last_run = now_minus_24h
|
last_run = now_minus_24h
|
||||||
last_cleanup = now_minus_24h
|
last_cleanup = now_minus_24h
|
||||||
last_update_vendors = time_started - datetime.timedelta(days = 6) # update vendors 24h after first run and than once a week
|
last_update_vendors = time_started - datetime.timedelta(days = 6) # update vendors 24h after first run and then once a week
|
||||||
|
|
||||||
# indicates, if a new version is available
|
# indicates, if a new version is available
|
||||||
newVersionAvailable = False
|
newVersionAvailable = False
|
||||||
@@ -2138,10 +2139,11 @@ def send_notifications ():
|
|||||||
|
|
||||||
deviceUrl = REPORT_DASHBOARD_URL + '/deviceDetails.php?mac='
|
deviceUrl = REPORT_DASHBOARD_URL + '/deviceDetails.php?mac='
|
||||||
table_attributes = {"style" : "border-collapse: collapse; font-size: 12px; color:#70707", "width" : "100%", "cellspacing" : 0, "cellpadding" : "3px", "bordercolor" : "#C0C0C0", "border":"1"}
|
table_attributes = {"style" : "border-collapse: collapse; font-size: 12px; color:#70707", "width" : "100%", "cellspacing" : 0, "cellpadding" : "3px", "bordercolor" : "#C0C0C0", "border":"1"}
|
||||||
headerProps = "width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' "
|
headerProps = "width='120px' style='color:blue; font-size: 16px;' bgcolor='#909090' "
|
||||||
thProps = "width='120px' style='color:#F0F0F0' bgcolor='#909090' "
|
thProps = "width='120px' style='color:#F0F0F0' bgcolor='#909090' "
|
||||||
|
|
||||||
build_direction = "TOP_TO_BOTTOM"
|
build_direction = "TOP_TO_BOTTOM"
|
||||||
|
text_line = '{}\t\t{}\n'
|
||||||
|
|
||||||
# Reporting section
|
# Reporting section
|
||||||
file_print(' Check if something to report')
|
file_print(' Check if something to report')
|
||||||
@@ -2205,11 +2207,10 @@ def send_notifications ():
|
|||||||
headers = ["MAC", "Datetime", "IP", "Event Type", "Additional info"]
|
headers = ["MAC", "Datetime", "IP", "Event Type", "Additional info"]
|
||||||
|
|
||||||
# prepare text-only message
|
# prepare text-only message
|
||||||
text_line = '{}\t{}\n'
|
|
||||||
|
|
||||||
for device in json_string["data"]:
|
for device in json_string["data"]:
|
||||||
for header in headers:
|
for header in headers:
|
||||||
text += text_line.format ( header + ': ', device[header])
|
text += text_line.format ( header + ': ', device[header])
|
||||||
|
text += '\n'
|
||||||
|
|
||||||
# Format HTML table headers
|
# Format HTML table headers
|
||||||
for header in headers:
|
for header in headers:
|
||||||
@@ -2238,12 +2239,12 @@ def send_notifications ():
|
|||||||
|
|
||||||
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
||||||
|
|
||||||
# prepare text-only message
|
# prepare text-only message
|
||||||
text_line = '{}\t{}\n'
|
|
||||||
text = ""
|
text = ""
|
||||||
for device in json_string["data"]:
|
for device in json_string["data"]:
|
||||||
for header in headers:
|
for header in headers:
|
||||||
text += text_line.format ( header + ': ', device[header])
|
text += text_line.format ( header + ': ', device[header])
|
||||||
|
text += '\n'
|
||||||
|
|
||||||
# Format HTML table headers
|
# Format HTML table headers
|
||||||
for header in headers:
|
for header in headers:
|
||||||
@@ -2273,12 +2274,12 @@ def send_notifications ():
|
|||||||
|
|
||||||
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
||||||
|
|
||||||
# prepare text-only message
|
# prepare text-only message
|
||||||
text_line = '{}\t{}\n'
|
|
||||||
text = ""
|
text = ""
|
||||||
for device in json_string["data"]:
|
for device in json_string["data"]:
|
||||||
for header in headers:
|
for header in headers:
|
||||||
text += text_line.format ( header + ': ', device[header])
|
text += text_line.format ( header + ': ', device[header])
|
||||||
|
text += '\n'
|
||||||
|
|
||||||
# Format HTML table headers
|
# Format HTML table headers
|
||||||
for header in headers:
|
for header in headers:
|
||||||
@@ -2308,12 +2309,12 @@ def send_notifications ():
|
|||||||
|
|
||||||
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
headers = ["MAC", "Datetime", "IP", "Event Type", "Device name", "Comments"]
|
||||||
|
|
||||||
# prepare text-only message
|
# prepare text-only message
|
||||||
text_line = '{}\t{}\n'
|
|
||||||
text = ""
|
text = ""
|
||||||
for device in json_string["data"]:
|
for device in json_string["data"]:
|
||||||
for header in headers:
|
for header in headers:
|
||||||
text += text_line.format ( header + ': ', device[header])
|
text += text_line.format ( header + ': ', device[header])
|
||||||
|
text += '\n'
|
||||||
|
|
||||||
# Format HTML table headers
|
# Format HTML table headers
|
||||||
for header in headers:
|
for header in headers:
|
||||||
@@ -2375,7 +2376,7 @@ def send_notifications ():
|
|||||||
if REPORT_APPRISE and check_config('apprise'):
|
if REPORT_APPRISE and check_config('apprise'):
|
||||||
updateState("Send: Apprise")
|
updateState("Send: Apprise")
|
||||||
file_print(' Sending report by Apprise')
|
file_print(' Sending report by Apprise')
|
||||||
send_apprise (mail_html)
|
send_apprise (mail_html, mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip Apprise')
|
file_print(' Skip Apprise')
|
||||||
if REPORT_WEBHOOK and check_config('webhook'):
|
if REPORT_WEBHOOK and check_config('webhook'):
|
||||||
@@ -2679,17 +2680,22 @@ def send_webhook (_json, _html):
|
|||||||
file_print(e.output)
|
file_print(e.output)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def send_apprise (html):
|
def send_apprise (html, text):
|
||||||
#Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
|
#Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
|
||||||
|
payload = html
|
||||||
|
|
||||||
|
if APPRISE_PAYLOAD == 'text':
|
||||||
|
payload = text
|
||||||
|
|
||||||
_json_payload={
|
_json_payload={
|
||||||
"urls": APPRISE_URL,
|
"urls": APPRISE_URL,
|
||||||
"title": "Pi.Alert Notifications",
|
"title": "Pi.Alert Notifications",
|
||||||
"format": "html",
|
"format": APPRISE_PAYLOAD,
|
||||||
"body": html
|
"body": payload
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# try runnning a subprocess
|
# try runnning a subprocess
|
||||||
p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), APPRISE_HOST], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), APPRISE_HOST], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
# write stdout and stderr into .log files for debugging if needed
|
# write stdout and stderr into .log files for debugging if needed
|
||||||
@@ -3379,7 +3385,7 @@ def handle_test(testType):
|
|||||||
if testType == 'REPORT_WEBHOOK':
|
if testType == 'REPORT_WEBHOOK':
|
||||||
send_webhook (sample_json_payload, sample_txt)
|
send_webhook (sample_json_payload, sample_txt)
|
||||||
if testType == 'REPORT_APPRISE':
|
if testType == 'REPORT_APPRISE':
|
||||||
send_apprise (sample_html)
|
send_apprise (sample_html, sample_txt)
|
||||||
if testType == 'REPORT_NTFY':
|
if testType == 'REPORT_NTFY':
|
||||||
send_ntfy (sample_txt)
|
send_ntfy (sample_txt)
|
||||||
if testType == 'REPORT_PUSHSAFER':
|
if testType == 'REPORT_PUSHSAFER':
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||||
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||||
- ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db
|
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||||
# (optional) useful for debugging if you have issues setting up the container
|
# (optional) useful for debugging if you have issues setting up the container
|
||||||
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
||||||
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes
|
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes
|
||||||
- ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py
|
- ${DEV_LOCATION}/back:/home/pi/pialert/back
|
||||||
- ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh
|
|
||||||
- ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html
|
|
||||||
- ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus
|
- ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus
|
||||||
- ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles
|
- ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles
|
||||||
- ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
|
- ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ $lang['en_us'] = array(
|
|||||||
'DevDetail_MainInfo_Owner' => 'Owner',
|
'DevDetail_MainInfo_Owner' => 'Owner',
|
||||||
'DevDetail_MainInfo_Type' => 'Type',
|
'DevDetail_MainInfo_Type' => 'Type',
|
||||||
'DevDetail_Icon' => 'Icon',
|
'DevDetail_Icon' => 'Icon',
|
||||||
'DevDetail_Icon_Descr' => 'Enter a font awesome icon name without the fa- prefix.',
|
'DevDetail_Icon_Descr' => 'Enter a font awesome icon name without the fa- prefix or with complete class, e.g.: fa fa-brands fa-apple.',
|
||||||
'DevDetail_MainInfo_Vendor' => 'Vendor',
|
'DevDetail_MainInfo_Vendor' => 'Vendor',
|
||||||
'DevDetail_MainInfo_Favorite' => 'Favorite',
|
'DevDetail_MainInfo_Favorite' => 'Favorite',
|
||||||
'DevDetail_MainInfo_Group' => 'Group',
|
'DevDetail_MainInfo_Group' => 'Group',
|
||||||
@@ -555,7 +555,7 @@ the arp-scan will take hours to complete instead of seconds.
|
|||||||
'APPRISE_HOST_name' => 'Apprise host URL',
|
'APPRISE_HOST_name' => 'Apprise host URL',
|
||||||
'APPRISE_HOST_description' => 'Apprise host URL starting with <code>http://</code> or <code>https://</code>. (don\'t forget to include <code>/notify</code> at the end)',
|
'APPRISE_HOST_description' => 'Apprise host URL starting with <code>http://</code> or <code>https://</code>. (don\'t forget to include <code>/notify</code> at the end)',
|
||||||
'APPRISE_URL_name' => 'Apprise notification URL',
|
'APPRISE_URL_name' => 'Apprise notification URL',
|
||||||
'APPRISE_URL_description' => 'Apprise notification target URL.',
|
'APPRISE_URL_description' => 'Apprise notification target URL. For example for Telegram it would be <code>tgram://{bot_token}/{chat_id}</code>.',
|
||||||
|
|
||||||
// NTFY
|
// NTFY
|
||||||
'NTFY_settings_group' => '<i class="fa fa-terminal"></i> NTFY',
|
'NTFY_settings_group' => '<i class="fa fa-terminal"></i> NTFY',
|
||||||
@@ -576,6 +576,8 @@ the arp-scan will take hours to complete instead of seconds.
|
|||||||
'REPORT_PUSHSAFER_description' => 'Enable sending notifications via <a target="_blank" href="https://www.pushsafer.com/">Pushsafer</a>.',
|
'REPORT_PUSHSAFER_description' => 'Enable sending notifications via <a target="_blank" href="https://www.pushsafer.com/">Pushsafer</a>.',
|
||||||
'PUSHSAFER_TOKEN_name' => 'Pushsafer token',
|
'PUSHSAFER_TOKEN_name' => 'Pushsafer token',
|
||||||
'PUSHSAFER_TOKEN_description' => 'Your secret Pushsafer API key (token).',
|
'PUSHSAFER_TOKEN_description' => 'Your secret Pushsafer API key (token).',
|
||||||
|
'APPRISE_PAYLOAD_name' => 'Payload type',
|
||||||
|
'APPRISE_PAYLOAD_description' => 'Select the payoad type sent to Apprise. For example <code>html</code> works well with emails, <code>text</code> with chat apps, such as Telegram.',
|
||||||
|
|
||||||
|
|
||||||
// MQTT
|
// MQTT
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
// number of settings has to be equal to
|
// number of settings has to be equal to
|
||||||
var settingsNumber = 66;
|
var settingsNumber = 67;
|
||||||
|
|
||||||
// Wrong number of settings processing
|
// Wrong number of settings processing
|
||||||
if(<?php echo count($settings)?> != settingsNumber)
|
if(<?php echo count($settings)?> != settingsNumber)
|
||||||
|
|||||||
Reference in New Issue
Block a user