initial support for gotify
This commit is contained in:
parent
7f687282f8
commit
6ab9552341
|
@ -19,7 +19,7 @@ class MQTTClient:
|
||||||
self.mqtt_client.tls_set()
|
self.mqtt_client.tls_set()
|
||||||
self.mqtt_client.connect(server, 8883, 60)
|
self.mqtt_client.connect(server, 8883, 60)
|
||||||
self.mqtt_client.loop_start()
|
self.mqtt_client.loop_start()
|
||||||
self.logger.info('MQTT connection successfull')
|
self.logger.info('MQTT connection successful')
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.logger.error('MQTT connection failed: %s', str(err))
|
self.logger.error('MQTT connection failed: %s', str(err))
|
||||||
|
|
||||||
|
|
17
main.py
17
main.py
|
@ -13,6 +13,7 @@ from dotenv import find_dotenv, load_dotenv
|
||||||
from library.emailhandling import EmailHandling
|
from library.emailhandling import EmailHandling
|
||||||
from library.lodur import Lodur
|
from library.lodur import Lodur
|
||||||
from library.mqtt import MQTTClient
|
from library.mqtt import MQTTClient
|
||||||
|
from library.gotify import GotifyClient
|
||||||
from library.pdf_extract import PDFHandling
|
from library.pdf_extract import PDFHandling
|
||||||
from library.webdav import WebDav
|
from library.webdav import WebDav
|
||||||
|
|
||||||
|
@ -36,7 +37,9 @@ LODUR_USER = os.getenv("LODUR_USER")
|
||||||
LODUR_PASSWORD = os.getenv("LODUR_PASSWORD")
|
LODUR_PASSWORD = os.getenv("LODUR_PASSWORD")
|
||||||
LODUR_BASE_URL = os.getenv("LODUR_BASE_URL")
|
LODUR_BASE_URL = os.getenv("LODUR_BASE_URL")
|
||||||
HEARTBEAT_URL = os.getenv("HEARTBEAT_URL")
|
HEARTBEAT_URL = os.getenv("HEARTBEAT_URL")
|
||||||
PYLOKID_VERSION = "1.1.0"
|
GOTIFY_URL = os.getenv("GOTIFY_URL")
|
||||||
|
GOTIFY_TOKEN = os.getenv("GOTIFY_TOKEN")
|
||||||
|
PYLOKID_VERSION = "1.2.0"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main """
|
""" main """
|
||||||
|
@ -82,6 +85,12 @@ def main():
|
||||||
MQTT_BASE_TOPIC,
|
MQTT_BASE_TOPIC,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Initialize Gotify
|
||||||
|
gotify_client = GotifyClient(
|
||||||
|
GOTIFY_URL,
|
||||||
|
GOTIFY_TOKEN,
|
||||||
|
)
|
||||||
|
|
||||||
# Initialize PDF Parser
|
# Initialize PDF Parser
|
||||||
pdf = PDFHandling()
|
pdf = PDFHandling()
|
||||||
|
|
||||||
|
@ -124,8 +133,9 @@ def main():
|
||||||
f_id,
|
f_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# publish Einsatz on MQTT
|
# publish Einsatz on MQTT and Gotify
|
||||||
mqtt_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
mqtt_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
||||||
|
gotify_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
||||||
|
|
||||||
# create new Einsatzrapport in Lodur
|
# create new Einsatzrapport in Lodur
|
||||||
lodur_client.einsatzrapport(
|
lodur_client.einsatzrapport(
|
||||||
|
@ -163,8 +173,9 @@ def main():
|
||||||
# Update entry in Lodur with parse PDF data
|
# Update entry in Lodur with parse PDF data
|
||||||
lodur_client.einsatzprotokoll(f_id, pdf_data, webdav_client)
|
lodur_client.einsatzprotokoll(f_id, pdf_data, webdav_client)
|
||||||
|
|
||||||
# Einsatz finished - publish on MQTT
|
# Einsatz finished - publish on MQTT and Gotify
|
||||||
mqtt_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
mqtt_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
||||||
|
gotify_client.send_message(f_type, f_id, pdf_data, pdf_file)
|
||||||
else:
|
else:
|
||||||
logger.error(
|
logger.error(
|
||||||
'[%s] Cannot process Einsatzprotokoll as there is no Lodur ID',
|
'[%s] Cannot process Einsatzprotokoll as there is no Lodur ID',
|
||||||
|
|
Loading…
Reference in New Issue