mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Merge pull request #248 from Data-Monkey/split_it_up
fix issue #4 by @Data-Monkey
This commit is contained in:
@@ -24,10 +24,12 @@ arpscan_devices = []
|
|||||||
# for MQTT
|
# for MQTT
|
||||||
mqtt_connected_to_broker = False
|
mqtt_connected_to_broker = False
|
||||||
mqtt_sensors = []
|
mqtt_sensors = []
|
||||||
|
client = None # mqtt client
|
||||||
# for notifications
|
# for notifications
|
||||||
changedPorts_json_struc = None
|
changedPorts_json_struc = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ACTUAL CONFIGRATION ITEMS set to defaults
|
# ACTUAL CONFIGRATION ITEMS set to defaults
|
||||||
|
|
||||||
# General
|
# General
|
||||||
|
|||||||
@@ -146,8 +146,9 @@ def mqtt_start(db):
|
|||||||
|
|
||||||
if conf.mqtt_connected_to_broker == False:
|
if conf.mqtt_connected_to_broker == False:
|
||||||
conf.mqtt_connected_to_broker = True
|
conf.mqtt_connected_to_broker = True
|
||||||
client = mqtt_create_client()
|
conf.client = mqtt_create_client()
|
||||||
|
|
||||||
|
client = conf.client
|
||||||
# General stats
|
# General stats
|
||||||
|
|
||||||
# Create a generic device for overal stats
|
# Create a generic device for overal stats
|
||||||
@@ -175,7 +176,7 @@ def mqtt_start(db):
|
|||||||
# Specific devices
|
# Specific devices
|
||||||
|
|
||||||
# Get all devices
|
# Get all devices
|
||||||
devices = get_all_devices()
|
devices = get_all_devices(db)
|
||||||
|
|
||||||
sec_delay = len(devices) * int(conf.MQTT_DELAY_SEC)*5
|
sec_delay = len(devices) * int(conf.MQTT_DELAY_SEC)*5
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ def send (msg: noti_struc):
|
|||||||
# add authorization header with hash
|
# add authorization header with hash
|
||||||
headers["Authorization"] = "Basic {}".format(basichash)
|
headers["Authorization"] = "Basic {}".format(basichash)
|
||||||
|
|
||||||
|
try:
|
||||||
requests.post("{}/{}".format( conf.NTFY_HOST, conf.NTFY_TOPIC),
|
requests.post("{}/{}".format( conf.NTFY_HOST, conf.NTFY_TOPIC),
|
||||||
data=msg.html,
|
data=msg.html,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
mylog('none', ['[NTFY] Error: ', e])
|
||||||
|
return -1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user