mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-22 16:20:25 +01:00
commit
4321234499
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -13,6 +13,18 @@
|
|||
##### Security
|
||||
|
||||
|
||||
### __[v2.4.4]__ - unreleased
|
||||
##### Added
|
||||
- Divera-Plugin: Plugin zum Ansteuern der Divera-Api. [#415](https://github.com/Schrolli91/BOSWatch/pull/415)
|
||||
##### Changed
|
||||
- MySQL-Plugin: Index für die RIC Adresse hinzugefügt [#411](https://github.com/Schrolli91/BOSWatch/issues/411)
|
||||
- MySQL-Plugin: INSERT Befehl für MySQL 8.x angepasst, Spaltennamen escaped [#410](https://github.com/Schrolli91/BOSWatch/issues/410)
|
||||
##### Deprecated
|
||||
##### Removed
|
||||
##### Fixed
|
||||
##### Security
|
||||
|
||||
|
||||
### __[v2.4.3]__ - 22.09.2019
|
||||
##### Added
|
||||
- Telegram-Plugin: In der generierten Übersichtkarte wird eine Anfahrtsroute integriert. Der Abfahrtsort ist konfiguierbar. [#382](https://github.com/Schrolli91/BOSWatch/pull/382)
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ Pushover = 0
|
|||
Telegram = 0
|
||||
yowsup = 0
|
||||
hue = 0
|
||||
Divera = 0
|
||||
|
||||
# for developing - template-module
|
||||
template = 0
|
||||
|
|
@ -466,6 +467,37 @@ timeoff = 1
|
|||
# configure 0 to keep the switch on for infinite time or configure >=1 to keep it for the value in seconds to on, before switching to off.
|
||||
keepon = 60
|
||||
|
||||
[Divera]
|
||||
# See https://api.divera247.com/ for Api-Documentation
|
||||
# Title: Alarm-Stichwort (max. 50 Zeichen, in der kostenlosen Version max. 30 Zeichen)
|
||||
# Text: Alarm-Text (in der kostenlosen Version wird dies nicht übernommen)
|
||||
# Priority: true / false.
|
||||
# Wird ein anderer Wert oder gar keiner gesetzt, so wird die Divera-Alarmierung nicht durchgeführt.
|
||||
|
||||
# Divera API Key
|
||||
accesskey =
|
||||
|
||||
# Section for POCSAG
|
||||
# Adapt Pocsag Subric (a,b,c,d) to Divera Priorities (true/false)
|
||||
SubA = true
|
||||
SubB = false
|
||||
SubC =
|
||||
SubD =
|
||||
|
||||
poc_title = %DESCR%: %MSG%
|
||||
poc_text = %DATE% %TIME% - %DESCR%: %MSG%
|
||||
|
||||
# Section for ZVEI
|
||||
# default prio for all ZVEI - except you specify it different
|
||||
zvei_prio = true
|
||||
zvei_title = Alarm: %ZVEI%
|
||||
zvei_text = %DATE% %TIME%: %ZVEI%
|
||||
|
||||
# Section for FMS
|
||||
fms_prio = true
|
||||
fms_title = FMS: %FMS%
|
||||
fms_text = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR%
|
||||
|
||||
#####################
|
||||
##### Not ready yet #
|
||||
#####################
|
||||
|
|
|
|||
153
plugins/Divera/Divera.py
Normal file
153
plugins/Divera/Divera.py
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
"""
|
||||
Divera-Plugin to send FMS-, ZVEI- and POCSAG - messages to Divera
|
||||
@author: Marco Grosjohann
|
||||
@requires: Divera-Configuration has to be set in the config.ini
|
||||
"""
|
||||
|
||||
import logging # Global logger
|
||||
import httplib # for the HTTP request
|
||||
import urllib
|
||||
from includes import globalVars # Global variables
|
||||
|
||||
# from includes.helper import timeHandler
|
||||
from includes.helper import configHandler
|
||||
from includes.helper import wildcardHandler
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# onLoad (init) function of plugin
|
||||
# will be called one time by the pluginLoader on start
|
||||
#
|
||||
def onLoad():
|
||||
"""
|
||||
While loading the plugins by pluginLoader.loadPlugins()
|
||||
this onLoad() routine is called one time for initialize the plugin
|
||||
@requires: nothing
|
||||
@return: nothing
|
||||
"""
|
||||
# nothing to do for this plugin
|
||||
return
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# Main function of Divera-plugin
|
||||
# will be called by the alarmHandler
|
||||
#
|
||||
def run(typ, freq, data):
|
||||
"""
|
||||
This function is the implementation of the Divera-Plugin.
|
||||
It will send the data to Divera API
|
||||
@type typ: string (FMS|ZVEI|POC)
|
||||
@param typ: Typ of the dataset
|
||||
@type data: map of data (structure see readme.md in plugin folder)
|
||||
@param data: Contains the parameter
|
||||
@type freq: string
|
||||
@keyword freq: frequency of the SDR Stick
|
||||
@requires: Divera-Configuration has to be set in the config.ini
|
||||
@return: nothing
|
||||
"""
|
||||
try:
|
||||
if configHandler.checkConfig("Divera"): # read and debug the config
|
||||
|
||||
if typ == "FMS":
|
||||
#
|
||||
# building message for FMS
|
||||
#
|
||||
text = globalVars.config.get("Divera", "fms_text")
|
||||
title = globalVars.config.get("Divera", "fms_title")
|
||||
priority = globalVars.config.get("Divera", "fms_prio")
|
||||
|
||||
elif typ == "ZVEI":
|
||||
#
|
||||
# building message for ZVEI
|
||||
#
|
||||
text = globalVars.config.get("Divera", "zvei_text")
|
||||
title = globalVars.config.get("Divera", "zvei_title")
|
||||
priority = globalVars.config.get("Divera","zvei_std_prio")
|
||||
|
||||
elif typ == "POC":
|
||||
#
|
||||
# building message for POC
|
||||
#
|
||||
if data["function"] == '1':
|
||||
priority = globalVars.config.get("Divera", "SubA")
|
||||
elif data["function"] == '2':
|
||||
priority = globalVars.config.get("Divera", "SubB")
|
||||
elif data["function"] == '3':
|
||||
priority = globalVars.config.get("Divera", "SubC")
|
||||
elif data["function"] == '4':
|
||||
priority = globalVars.config.get("Divera", "SubD")
|
||||
else:
|
||||
priority = ''
|
||||
|
||||
text = globalVars.config.get("Divera", "poc_text")
|
||||
title = globalVars.config.get("Divera", "poc_title")
|
||||
|
||||
else:
|
||||
logging.warning("Invalid type: %s", typ)
|
||||
return
|
||||
|
||||
try:
|
||||
#
|
||||
# Divera-Request
|
||||
#
|
||||
logging.debug("send Divera for %s", typ)
|
||||
|
||||
# replace the wildcards
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
title = wildcardHandler.replaceWildcards(title, data)
|
||||
|
||||
# Logging data to send
|
||||
logging.debug("Title : %s", title)
|
||||
logging.debug("Text : %s", text)
|
||||
logging.debug("Priority: %s", priority)
|
||||
|
||||
# check priority value
|
||||
if (priority != 'false') and (priority != 'true'):
|
||||
logging.info("No Priority set for type '%s'! Skipping Divera-Alarm!", typ)
|
||||
return
|
||||
|
||||
# start the connection
|
||||
conn = httplib.HTTPSConnection("www.divera247.com:443")
|
||||
conn.request("GET", "/api/alarm",
|
||||
urllib.urlencode({
|
||||
"accesskey": globalVars.config.get("Divera", "accesskey"),
|
||||
"title": title,
|
||||
"text": text,
|
||||
"priority": priority,
|
||||
}))
|
||||
|
||||
except:
|
||||
logging.error("cannot send Divera request")
|
||||
logging.debug("cannot send Divera request", exc_info=True)
|
||||
return
|
||||
|
||||
try:
|
||||
#
|
||||
# check Divera-Response
|
||||
#
|
||||
response = conn.getresponse()
|
||||
if str(response.status) == "200": # Check Divera Response and print a Log or Error
|
||||
logging.debug("Divera response: %s - %s", str(response.status), str(response.reason))
|
||||
else:
|
||||
logging.warning("Divera response: %s - %s", str(response.status), str(response.reason))
|
||||
except: # otherwise
|
||||
logging.error("cannot get Divera response")
|
||||
logging.debug("cannot get Divera response", exc_info=True)
|
||||
return
|
||||
|
||||
finally:
|
||||
logging.debug("close Divera-Connection")
|
||||
try:
|
||||
request.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
except:
|
||||
logging.error("unknown error")
|
||||
logging.debug("unknown error", exc_info=True)
|
||||
Loading…
Reference in a new issue