From 860f3d5e7dcb50da0d709fdb1cf3d9f296b310e4 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 22 Sep 2019 09:43:37 +0200 Subject: [PATCH 01/41] prepare dev for next release --- CHANGELOG.md | 8 ++++++++ includes/globalVars.py | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab81cb5..27766f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### __[v2.4.4]__ - unreleased +##### Added +##### Changed +##### Deprecated +##### Removed +##### Fixed +##### Security + ### __[v2.4.3]__ - 22.09.1991 ##### Added diff --git a/includes/globalVars.py b/includes/globalVars.py index 3f197cb..d0edd2a 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,9 +9,9 @@ Global variables """ # version info -versionNr = "2.4.3" -branch = "master" -buildDate = "22.09.2019" +versionNr = "2.4.4" +branch = "dev" +buildDate = "unreleased" # Global variables config = 0 From 51709d0a613cdf7b5dc9053b7f9eb6a3ceba24a7 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 24 Sep 2019 10:08:40 +0200 Subject: [PATCH 02/41] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27766f3..f19cb6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ##### Security -### __[v2.4.3]__ - 22.09.1991 +### __[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) - Hue-Plugin: Geräte die mit einer Hue bridge verbunden sind können aus BOSWatch ein- und ausgeschaltet werden. [#394](https://github.com/Schrolli91/BOSWatch/issues/394) From 82448a737a2874e18d2dab24d760b4c5ad1b831e Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 26 Sep 2019 21:25:11 +0200 Subject: [PATCH 03/41] Update poc.py --- includes/decoders/poc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 6ab9aa0..6fd33e1 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -34,6 +34,7 @@ def isAllowed(poc_id): """ allowed = 0 + has_geo = False # 1.) If allowed RICs is set, only they will path, # If RIC is the right one return True, else False From 9e0e4485201ed3da6c4864ebf87530bc37b7557e Mon Sep 17 00:00:00 2001 From: kruegerj Date: Fri, 4 Oct 2019 14:05:48 +0200 Subject: [PATCH 04/41] Update MySQL.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INSERT in die Pocsag Tabelle schlägt fehl, da function bei MySQL 8.0 als reserviertes Wort nicht einfach als Spaltenname genutzt werden kann. Siehe auch https://dev.mysql.com/doc/refman/8.0/en/keywords.html Daher habe ich nun die Spaltennamen escaped, damit funktioniert wieder ein INSERT in MySQL 8.0 Datenbanken --- plugins/MySQL/MySQL.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index c38410f..489dbe6 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -104,21 +104,21 @@ def run(typ,freq,data): logging.debug("Insert %s", typ) if typ == "FMS": - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableFMS")+" (time, fms, status, direction, directionText, tsi, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["fms"], data["status"], data["direction"], data["directionText"], data["tsi"], data["description"])) + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableFMS")+" (`time`, `fms`, `status`, `direction`, `directionText`, `tsi`, `description`) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["fms"], data["status"], data["direction"], data["directionText"], data["tsi"], data["description"])) elif typ == "ZVEI": - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableZVEI")+" (time, zvei, description) VALUES (FROM_UNIXTIME(%s),%s,%s)", (data["timestamp"], data["zvei"], data["description"])) + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableZVEI")+" (`time`, `zvei`, `description`) VALUES (FROM_UNIXTIME(%s),%s,%s)", (data["timestamp"], data["zvei"], data["description"])) elif typ == "POC": if isSignal(data["ric"]): if globalVars.config.getint("POC","netIdent_history"): - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');") + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (`time`,`ric`) VALUES (NOW(), '"+data["ric"]+"');") else: cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';") if cursor.rowcount == 0: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');") + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (`time`,`ric`) VALUES (NOW(), '"+data["ric"]+"');") else: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"])) + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (`time`, `ric`, `function`, `functionChar`, `msg`, `bitrate`, `description`) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"])) else: logging.warning("Invalid Typ: %s", typ) From 2da87a46dd6ae612f66d2a3f340cae72ce6db62e Mon Sep 17 00:00:00 2001 From: kruegerj Date: Fri, 4 Oct 2019 14:09:05 +0200 Subject: [PATCH 05/41] Update boswatch.sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Key auf die RIC Spalte hinzugefügt --- plugins/MySQL/boswatch.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 6f93861..77f35c8 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -70,7 +70,8 @@ CREATE TABLE IF NOT EXISTS `bos_pocsag` ( `msg` TEXT NOT NULL, `bitrate` INT(4) NOT NULL, `description` TEXT NOT NULL, - PRIMARY KEY (`ID`) + PRIMARY KEY (`ID`), + KEY `POCSAG_RIC_IDX` (`ric`) ) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; -- rename old columns including little error-prevention From fa5acd4d79b3795ad07c8cce884127d784af84b0 Mon Sep 17 00:00:00 2001 From: kruegerj Date: Fri, 4 Oct 2019 20:39:39 +0200 Subject: [PATCH 06/41] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f19cb6f..d8b33af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ### __[v2.4.4]__ - unreleased ##### Added ##### Changed +Index für die RIC Adresse hinzugefügt #411(https://github.com/Schrolli91/BOSWatch/issues/394) +INSERT Befehl für MySQL 8.x angepasst, Spaltennamen escaped #410(https://github.com/Schrolli91/BOSWatch/issues/410) ##### Deprecated ##### Removed ##### Fixed From edb2329ab7cf4af6b0f62a31d502caa6a5045913 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 4 Oct 2019 21:58:47 +0200 Subject: [PATCH 07/41] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8b33af..c3b436a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,8 @@ ### __[v2.4.4]__ - unreleased ##### Added ##### Changed -Index für die RIC Adresse hinzugefügt #411(https://github.com/Schrolli91/BOSWatch/issues/394) -INSERT Befehl für MySQL 8.x angepasst, Spaltennamen escaped #410(https://github.com/Schrolli91/BOSWatch/issues/410) +- MySQL-Plugin: Index für die RIC Adresse hinzugefügt [#411](https://github.com/Schrolli91/BOSWatch/issues/394) +- MySQL-Plugin: INSERT Befehl für MySQL 8.x angepasst, Spaltennamen escaped [#410](https://github.com/Schrolli91/BOSWatch/issues/410) ##### Deprecated ##### Removed ##### Fixed From 58c3a9134bb0d9f093f5918328d7e50d14f1c0b2 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 4 Oct 2019 21:59:25 +0200 Subject: [PATCH 08/41] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b436a..69e7a18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### __[v2.4.4]__ - unreleased ##### Added ##### Changed -- MySQL-Plugin: Index für die RIC Adresse hinzugefügt [#411](https://github.com/Schrolli91/BOSWatch/issues/394) +- MySQL-Plugin: Index für die RIC Adresse hinzugefügt [#411](https://github.com/Schrolli91/BOSWatch/issues/311) - MySQL-Plugin: INSERT Befehl für MySQL 8.x angepasst, Spaltennamen escaped [#410](https://github.com/Schrolli91/BOSWatch/issues/410) ##### Deprecated ##### Removed From 9a8a00ef83edbaae15c032e1e05c8a1605490d27 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 4 Oct 2019 21:59:47 +0200 Subject: [PATCH 09/41] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e7a18..5fbf24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### __[v2.4.4]__ - unreleased ##### Added ##### Changed -- MySQL-Plugin: Index für die RIC Adresse hinzugefügt [#411](https://github.com/Schrolli91/BOSWatch/issues/311) +- 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 From 85fcba43a50026930efc10826a11335cb4646b3d Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 7 Oct 2019 12:16:32 +0200 Subject: [PATCH 10/41] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fbf24f..6ee1b7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,8 @@ - Telegram-Plugin: In der generierten Übersichtkarte wird eine Anfahrtsroute integriert. Der Abfahrtsort ist konfiguierbar. [#382](https://github.com/Schrolli91/BOSWatch/pull/382) - Hue-Plugin: Geräte die mit einer Hue bridge verbunden sind können aus BOSWatch ein- und ausgeschaltet werden. [#394](https://github.com/Schrolli91/BOSWatch/issues/394) ##### Changed -- FFAgent Plugin: zusätzliches OrderedDict "alarmHeadersOrdered" implementiert um das HTTP Header Ordering sicherzustellen. Zusätzlich den HTTP Request mittels Session implementiert um das Header Ordering zu bewahren. Zusätzliches Debug Logging für die Header implementiert. [#356] (https://github.com/Schrolli91/BOSWatch/issues/356) -- POC-Decoder: Im POC-Text wird nach einem RegEx, welcher Koordinaten enthält, gesucht. Werden diese gefunden, so stehen zwei neu befüllte Data-Felder Lon bzw Lat zur Verfügung. +- FFAgent Plugin: zusätzliches OrderedDict "alarmHeadersOrdered" implementiert um das HTTP Header Ordering sicherzustellen. Zusätzlich den HTTP Request mittels Session implementiert um das Header Ordering zu bewahren. Zusätzliches Debug Logging für die Header implementiert. [#356](https://github.com/Schrolli91/BOSWatch/issues/356) +- POC-Decoder: Im POC-Text wird nach einem RegEx, welcher Koordinaten enthält, gesucht. Werden diese gefunden, so stehen zwei neu befüllte Data-Felder Lon bzw Lat zur Verfügung. [#405](https://github.com/Schrolli91/BOSWatch/pull/405) ##### Fixed - Asynchrone Alarme: Bei asynchroner Verarbeitung von schnell aufeinander folgenden Alarmen, wurde der Inhalt der Objekte typ, freq und data bereits vor dem Abschluss der Verarbeitung eines Alarms wieder überschrieben. Ergebnis hiervon war die Vermischung von RICs und Texten unterschiedlicher Alarme. Lösung über copy.deepcopy() [#394](https://github.com/Schrolli91/BOSWatch/issues/394) From 057945be47cb481056ecbc5084653f2c27e22b39 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 14 Oct 2019 09:10:27 +0200 Subject: [PATCH 11/41] cherrypick hotfix from master (#414) --- includes/decoders/poc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 6fd33e1..e5b9b6d 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -99,6 +99,8 @@ def decode(freq, decoded): @return: nothing @exception: Exception if POCSAG decode failed """ + has_geo = False + try: bitrate = 0 From 13073ec75a0302cc1ec9d483860b87ffdbdcf813 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 14 Oct 2019 09:17:26 +0200 Subject: [PATCH 12/41] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ee1b7b..659e00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - POC-Decoder: Im POC-Text wird nach einem RegEx, welcher Koordinaten enthält, gesucht. Werden diese gefunden, so stehen zwei neu befüllte Data-Felder Lon bzw Lat zur Verfügung. [#405](https://github.com/Schrolli91/BOSWatch/pull/405) ##### Fixed - Asynchrone Alarme: Bei asynchroner Verarbeitung von schnell aufeinander folgenden Alarmen, wurde der Inhalt der Objekte typ, freq und data bereits vor dem Abschluss der Verarbeitung eines Alarms wieder überschrieben. Ergebnis hiervon war die Vermischung von RICs und Texten unterschiedlicher Alarme. Lösung über copy.deepcopy() [#394](https://github.com/Schrolli91/BOSWatch/issues/394) +- POC-Decoder: Bug wegen nicht zugeweisener Variable 'has_geo' [#410](https://github.com/Schrolli91/BOSWatch/issues/413) [HOTFIX] ### __[v2.4.2]__ - 11.03.2019 From 4b8f64795b738f25839a631bd0b6ee02f7d30878 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Tue, 15 Oct 2019 08:40:12 +0200 Subject: [PATCH 13/41] Add Section for Divera-Plugin --- config/config.template.ini | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index 9e05679..955fc5f 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -175,6 +175,7 @@ Pushover = 0 Telegram = 0 yowsup = 0 hue = 0 +Divera = 0 # for developing - template-module template = 0 @@ -463,6 +464,32 @@ 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://www.divera247.com/documentation/local-management-alarm-api.html for Api-Documentation +# Divera API Key +accesskey = + +# Section for POCSAG +# Adapt Pocsag Subric (a,b,c,d) to Divera Priorities (true/false) +SubA = true +SubB = false +SubC = false +SubD = false + +poc_type = %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_type = Alarm: %ZVEI% +zvei_test = %DATE% %TIME%: %ZVEI% + +# Section for FMS +fms_prio = true +fms_type = FMS: %FMS% +fms_text = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR% + ##################### ##### Not ready yet # ##################### From 656fe482c2ad9ee190497afd3db9ad0af4da6daf Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Tue, 15 Oct 2019 08:42:09 +0200 Subject: [PATCH 14/41] Plugin for Divera --- plugins/Divera/Divera.py | 152 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 plugins/Divera/Divera.py diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py new file mode 100644 index 0000000..01db14b --- /dev/null +++ b/plugins/Divera/Divera.py @@ -0,0 +1,152 @@ +#!/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") + type = globalVars.config.get("Divera", "fms_type") + priority = globalVars.config.get("Divera", "fms_prio") + + elif typ == "ZVEI": + # + # building message for ZVEI + # + text = globalVars.config.get("Divera", "zvei_text") + type = globalVars.config.get("Divera", "zvei_type") + 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 = 'false' + + text = globalVars.config.get("Divera", "poc_text") + type = globalVars.config.get("Divera", "poc_type") + + 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) + type = wildcardHandler.replaceWildcards(type, data) + + # Logging data to send + logging.debug("Type : %s", type) + logging.debug("Text : %s", text) + logging.debug("Priority: %s", priority) + + # check priority value + if (priority != 'false') and (priority != 'true'): + priority = 'false' + + # start the connection + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/alarm", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "type": type, + "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) From 9f251bd544d9c3d6bc27263e81d0855fd6a6b3d7 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 15 Oct 2019 10:16:12 +0200 Subject: [PATCH 15/41] Update Divera.py correcting line indents --- plugins/Divera/Divera.py | 110 +++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 01db14b..98b8a15 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -68,20 +68,20 @@ def run(typ, freq, data): # text = globalVars.config.get("Divera", "zvei_text") type = globalVars.config.get("Divera", "zvei_type") - priority = globalVars.config.get("Divera","zvei_std_prio") + 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") + if data["function"] == '1': + priority = globalVars.config.get("Divera", "SubA") elif data["function"] == '2': - priority = globalVars.config.get("Divera", "SubB") + 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") + elif data["function"] == '4': + priority = globalVars.config.get("Divera", "SubD") else: priority = 'false' @@ -90,62 +90,62 @@ def run(typ, freq, data): else: logging.warning("Invalid type: %s", typ) - return + return - try: - # - # Divera-Request - # - logging.debug("send Divera for %s", typ) + try: + # + # Divera-Request + # + logging.debug("send Divera for %s", typ) - # replace the wildcards - text = wildcardHandler.replaceWildcards(text, data) - type = wildcardHandler.replaceWildcards(type, data) - - # Logging data to send - logging.debug("Type : %s", type) - logging.debug("Text : %s", text) - logging.debug("Priority: %s", priority) + # replace the wildcards + text = wildcardHandler.replaceWildcards(text, data) + type = wildcardHandler.replaceWildcards(type, data) + + # Logging data to send + logging.debug("Type : %s", type) + logging.debug("Text : %s", text) + logging.debug("Priority: %s", priority) - # check priority value - if (priority != 'false') and (priority != 'true'): - priority = 'false' + # check priority value + if (priority != 'false') and (priority != 'true'): + priority = 'false' - # start the connection - conn = httplib.HTTPSConnection("www.divera247.com:443") - conn.request("GET", "/api/alarm", - urllib.urlencode({ - "accesskey": globalVars.config.get("Divera", "accesskey"), - "type": type, - "text": text, - "priority": priority, - })) + # start the connection + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/alarm", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "type": type, + "text": text, + "priority": priority, + })) - except: - logging.error("cannot send Divera request") - logging.debug("cannot send Divera request", exc_info=True) - return + 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: - # - # 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 + request.close() + except: + pass except: logging.error("unknown error") From 6b638c55b2750d1f6e77997c70b62efe6bed2c2b Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Tue, 15 Oct 2019 10:46:38 +0200 Subject: [PATCH 16/41] Update line feeds --- plugins/Divera/Divera.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 98b8a15..8f92188 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -68,7 +68,7 @@ def run(typ, freq, data): # text = globalVars.config.get("Divera", "zvei_text") type = globalVars.config.get("Divera", "zvei_type") - priority = globalVars.config.get("Divera","zvei_std_prio") + priority = globalVars.config.get("Divera","zvei_std_prio") elif typ == "POC": # @@ -90,7 +90,7 @@ def run(typ, freq, data): else: logging.warning("Invalid type: %s", typ) - return + return try: # From 3d769976396804594e6e324e3f8bb12b1390776b Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Tue, 15 Oct 2019 11:18:16 +0200 Subject: [PATCH 17/41] Changlog zum Divera-Plugin --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c49c3..286d723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### __[Unreleased]__ - 15.10.2019 +##### Added +- Divera-Plugin: Plugin zum Ansteuern der Divera-Api. [#415](https://github.com/Schrolli91/BOSWatch/pull/415) ### __[v2.4.3]__ - 22.09.2019 ##### Added From c631692bac16a6eb4079035d3f74d0ecb1eacc30 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Oct 2019 11:01:53 +0200 Subject: [PATCH 18/41] Refactoring RegEx Changing RegEx to check entry; FMS containing chars inbetween had not been loaded, so the RegEx (l. 46) has been changed to correct it. Also: removing semicolon in l 105 --- includes/descriptionList.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 9e548fd..c61a46e 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -43,7 +43,7 @@ def loadCSV(typ, idField): for row in reader: logging.debug(row) # only import rows with an integer as id, allow subrics though - if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE): + if re.match("^[0-9A-Fa-f]+$", row[idField], re.IGNORECASE): try: resultList[row[idField].lower()] = stringConverter.convertToUTF8(row['description']) except: @@ -102,7 +102,7 @@ def getDescription(typ, data): @return: description as string """ - resultStr = data; + resultStr = data logging.debug("look up description lists") try: if typ == "FMS": From dc00fbc7a0271198cfafd80e71185783a79135fc Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Oct 2019 12:08:47 +0200 Subject: [PATCH 19/41] Update descriptionList.py Simplifying RegEx because of set IGNORECASE --- includes/descriptionList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index c61a46e..11281fd 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -43,7 +43,7 @@ def loadCSV(typ, idField): for row in reader: logging.debug(row) # only import rows with an integer as id, allow subrics though - if re.match("^[0-9A-Fa-f]+$", row[idField], re.IGNORECASE): + if re.match("^[0-9A-F]+$", row[idField], re.IGNORECASE): try: resultList[row[idField].lower()] = stringConverter.convertToUTF8(row['description']) except: From 3761eb8e28b391b302f05c7b170a859d9e3bb130 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Oct 2019 12:51:35 +0200 Subject: [PATCH 20/41] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659e00b..54a9483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ##### Deprecated ##### Removed ##### Fixed +- Description-List: Buchstaben in FMS-Kennungen werden nun erkannt und zugelassen [#409](https://github.com/Schrolli91/BOSWatch/issues/409) ##### Security From c00022d834f62cbff1c30b6c23977c3333651545 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Thu, 17 Oct 2019 14:47:51 +0200 Subject: [PATCH 21/41] =?UTF-8?q?Sound-Settings=20f=C3=BCr=20Pushover?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659e00b..27c0972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ##### 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) +- Pushover-Plugin: Konfigurationsmöglichkeit für den Sound. ##### Deprecated ##### Removed ##### Fixed From fd1c93326b0b4f6b954206fa4299455239e8ebed Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Thu, 17 Oct 2019 14:48:14 +0200 Subject: [PATCH 22/41] Update Pushover.py --- plugins/Pushover/Pushover.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/Pushover/Pushover.py b/plugins/Pushover/Pushover.py index 051445d..4d65785 100644 --- a/plugins/Pushover/Pushover.py +++ b/plugins/Pushover/Pushover.py @@ -128,6 +128,10 @@ def run(typ, freq, data): # replace the wildcards message = wildcardHandler.replaceWildcards(message, data) title = wildcardHandler.replaceWildcards(title, data) + sound = globalVars.config.get("Pushover", "sound") + # set Default-Sound + if not sound: + sound = "pushover" # start the connection conn = httplib.HTTPSConnection("api.pushover.net:443") @@ -138,6 +142,7 @@ def run(typ, freq, data): "message": message, "html": globalVars.config.get("Pushover", "html"), "title": title, + "sound": sound, "priority": priority, "retry": globalVars.config.get("Pushover", "retry"), "expire": globalVars.config.get("Pushover", "expire") From 6ded6578992970f6137240f22bb02977dc5890d3 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 17 Oct 2019 14:56:56 +0200 Subject: [PATCH 23/41] add link in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c0972..ea95756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ##### 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) -- Pushover-Plugin: Konfigurationsmöglichkeit für den Sound. +- Pushover-Plugin: Konfigurationsmöglichkeit für den Sound [#418](https://github.com/Schrolli91/BOSWatch/issues/418) ##### Deprecated ##### Removed ##### Fixed From d432a423fb1ea39d44caa23adbc54796e4cee445 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Thu, 17 Oct 2019 15:23:18 +0200 Subject: [PATCH 24/41] =?UTF-8?q?Config=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.template.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index 9e05679..d42fd6f 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -351,6 +351,9 @@ api_key = # Pushover Userkey or Groupkey to receive message user_key = +# Pushover Sound +sound = + # Section for POCSAG # Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority) SubA = 1 From 0181075d3e669313eea119e10baf88092e216263 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Mon, 21 Oct 2019 15:15:57 +0200 Subject: [PATCH 25/41] Update config.template.ini --- config/config.template.ini | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 955fc5f..28a3a2f 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -465,7 +465,9 @@ timeoff = 1 keepon = 60 [Divera] -#See https://www.divera247.com/documentation/local-management-alarm-api.html for Api-Documentation +# See https://api.divera247.com/ for Api-Documentation +# Title: Alarm-Stichwort (max. 50 Zeichen, in der kostenlosen Version max. 30 Zeichen) + # Divera API Key accesskey = @@ -476,18 +478,18 @@ SubB = false SubC = false SubD = false -poc_type = %DESCR%: %MSG% +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_type = Alarm: %ZVEI% +zvei_title = Alarm: %ZVEI% zvei_test = %DATE% %TIME%: %ZVEI% # Section for FMS fms_prio = true -fms_type = FMS: %FMS% +fms_title = FMS: %FMS% fms_text = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR% ##################### From 0dfe1ee89cd5cf24a8751ce3f41aabbca4b41c1e Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Mon, 21 Oct 2019 15:19:27 +0200 Subject: [PATCH 26/41] Anpassung auf Divera-Schnittstelle Die Divera-API ist unter https://api.divera247.com beschrieben. Anpassungen an diese Schnittstellenbeschreibung. Aus type wurde title. --- plugins/Divera/Divera.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 8f92188..a31dca8 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -59,7 +59,7 @@ def run(typ, freq, data): # building message for FMS # text = globalVars.config.get("Divera", "fms_text") - type = globalVars.config.get("Divera", "fms_type") + title = globalVars.config.get("Divera", "fms_title") priority = globalVars.config.get("Divera", "fms_prio") elif typ == "ZVEI": @@ -67,7 +67,7 @@ def run(typ, freq, data): # building message for ZVEI # text = globalVars.config.get("Divera", "zvei_text") - type = globalVars.config.get("Divera", "zvei_type") + title = globalVars.config.get("Divera", "zvei_title") priority = globalVars.config.get("Divera","zvei_std_prio") elif typ == "POC": @@ -86,7 +86,7 @@ def run(typ, freq, data): priority = 'false' text = globalVars.config.get("Divera", "poc_text") - type = globalVars.config.get("Divera", "poc_type") + title = globalVars.config.get("Divera", "poc_title") else: logging.warning("Invalid type: %s", typ) @@ -100,10 +100,10 @@ def run(typ, freq, data): # replace the wildcards text = wildcardHandler.replaceWildcards(text, data) - type = wildcardHandler.replaceWildcards(type, data) + title = wildcardHandler.replaceWildcards(title, data) # Logging data to send - logging.debug("Type : %s", type) + logging.debug("Title : %s", title) logging.debug("Text : %s", text) logging.debug("Priority: %s", priority) @@ -116,7 +116,7 @@ def run(typ, freq, data): conn.request("GET", "/api/alarm", urllib.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), - "type": type, + "title": title, "text": text, "priority": priority, })) From ddbddbbcdd8ea986a546e2bd4cecd372fb5deed5 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Mon, 4 Nov 2019 08:19:41 +0100 Subject: [PATCH 27/41] =?UTF-8?q?Keinen=20Default=20f=C3=BCr=20priority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ist kein Wert oder ein anderer Wert als true/false für priority gesetzt, wird ein Divera-Alarm ausgelassen. --- plugins/Divera/Divera.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index a31dca8..60092ed 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -83,7 +83,7 @@ def run(typ, freq, data): elif data["function"] == '4': priority = globalVars.config.get("Divera", "SubD") else: - priority = 'false' + priority = '' text = globalVars.config.get("Divera", "poc_text") title = globalVars.config.get("Divera", "poc_title") @@ -109,7 +109,8 @@ def run(typ, freq, data): # check priority value if (priority != 'false') and (priority != 'true'): - priority = 'false' + logging.info("No Priority set for type '%s'! Skipping Divera-Alarm!", typ) + return # start the connection conn = httplib.HTTPSConnection("www.divera247.com:443") From 3fc0e6d27a17dae678a4ed0181471d5cbef5ff75 Mon Sep 17 00:00:00 2001 From: grosj <56541936+grosj@users.noreply.github.com> Date: Mon, 4 Nov 2019 08:25:38 +0100 Subject: [PATCH 28/41] Update config.template.ini Beschreibung zum Divera-Plugin angepasst. Typo korrigiert. --- config/config.template.ini | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 28a3a2f..2ae9af2 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -467,6 +467,9 @@ 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 = @@ -475,8 +478,8 @@ accesskey = # Adapt Pocsag Subric (a,b,c,d) to Divera Priorities (true/false) SubA = true SubB = false -SubC = false -SubD = false +SubC = +SubD = poc_title = %DESCR%: %MSG% poc_text = %DATE% %TIME% - %DESCR%: %MSG% @@ -485,7 +488,7 @@ poc_text = %DATE% %TIME% - %DESCR%: %MSG% # default prio for all ZVEI - except you specify it different zvei_prio = true zvei_title = Alarm: %ZVEI% -zvei_test = %DATE% %TIME%: %ZVEI% +zvei_text = %DATE% %TIME%: %ZVEI% # Section for FMS fms_prio = true From c77391db88d2ccf84674e5d78b9a8dbde6edaae4 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 4 Nov 2019 11:56:45 +0100 Subject: [PATCH 29/41] fixed changelog --- CHANGELOG.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3501ff0..8d43f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### __[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) @@ -13,18 +14,6 @@ ##### 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) From 219eb3432260ac3d2fbc1c499dfa5392496dad42 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 29 Dec 2019 12:27:17 +0100 Subject: [PATCH 30/41] Update MySQL.py Full UTF-8 support. Update MySQL plugin and web UI to allow storage and display of emojis. --- plugins/MySQL/MySQL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index 489dbe6..04a8d08 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -91,7 +91,7 @@ def run(typ,freq,data): # Connect to MySQL # logging.debug("connect to MySQL") - connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), port = globalVars.config.get("MySQL","dbport"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8') + connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), port = globalVars.config.get("MySQL","dbport"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8mb4') cursor = connection.cursor() except: logging.error("cannot connect to MySQL") From 7d67bd87ac63cedee2708d46c2461b4e2449516d Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 29 Dec 2019 12:40:56 +0100 Subject: [PATCH 31/41] Update mysql.class.php Full UTF-8 support. Update MySQL plugin and web UI to allow storage and display of emojis. --- exampleAddOns/simpleWeb/mysql.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exampleAddOns/simpleWeb/mysql.class.php b/exampleAddOns/simpleWeb/mysql.class.php index a74b4b6..8aa1445 100644 --- a/exampleAddOns/simpleWeb/mysql.class.php +++ b/exampleAddOns/simpleWeb/mysql.class.php @@ -35,6 +35,10 @@ Simple Database Class (C) by Bastian Schroll $this->error("Datenbank nicht gefunden!", mysqli_error($this->conn)); return false; } + + /* Set character set for database connection to utf8mb4 */ + mysqli_query($this->conn, "SET NAMES 'utf8mb4'"); + return true; } From a7c657e447b35c79298522b475e9cc59c171592f Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 29 Dec 2019 13:30:13 +0100 Subject: [PATCH 32/41] Update boswatch.sql Full UTF-8 support. Update MySQL plugin and web UI to allow storage and display of emojis. --- plugins/MySQL/boswatch.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 77f35c8..8bf56d7 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -17,7 +17,7 @@ SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; +/*!40101 SET NAMES utf8mb4 */; -- -------------------------------------------------------- @@ -25,8 +25,8 @@ SET time_zone = "+00:00"; -- Datenbank anlegen `boswatch` -- -CREATE DATABASE IF NOT EXISTS boswatch; -USE boswatch; +CREATE DATABASE IF NOT EXISTS 'boswatch' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +USE 'boswatch'; -- -------------------------------------------------------- @@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `bos_fms` ( `tsi` VARCHAR(3) NOT NULL, `description` TEXT NOT NULL, PRIMARY KEY (`ID`) -) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=itf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; -- -------------------------------------------------------- @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS `bos_pocsag` ( `description` TEXT NOT NULL, PRIMARY KEY (`ID`), KEY `POCSAG_RIC_IDX` (`ric`) -) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; -- rename old columns including little error-prevention #ALTER IGNORE TABLE `bos_pocsag` change `funktion` `function` INT(1); @@ -90,7 +90,7 @@ CREATE TABLE IF NOT EXISTS `bos_zvei` ( `zvei` VARCHAR(5) NOT NULL DEFAULT '0', `description` TEXT NOT NULL, PRIMARY KEY (`ID`) -) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; -- -------------------------------------------------------- @@ -103,7 +103,7 @@ CREATE TABLE IF NOT EXISTS `bos_signal` ( `time` DATETIME NOT NULL, `ric` VARCHAR(7) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) -) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utb8mb4_unicode_ci AUTO_INCREMENT=1; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; From ad405829ea6751cd86fd4a60aa918966481691d2 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 29 Dec 2019 13:36:36 +0100 Subject: [PATCH 33/41] Update boswatch.sql Full UTF-8 support. Update MySQL plugin and web UI to allow storage and display of emojis. --- plugins/MySQL/boswatch.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 8bf56d7..cd044a8 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `bos_fms` ( `tsi` VARCHAR(3) NOT NULL, `description` TEXT NOT NULL, PRIMARY KEY (`ID`) -) ENGINE=MYISAM DEFAULT CHARSET=itf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; -- -------------------------------------------------------- @@ -103,7 +103,7 @@ CREATE TABLE IF NOT EXISTS `bos_signal` ( `time` DATETIME NOT NULL, `ric` VARCHAR(7) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) -) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utb8mb4_unicode_ci AUTO_INCREMENT=1; +) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; From 3c92d4285f7f50a98487e4f38c96f0821d457537 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 29 Dec 2019 13:44:10 +0100 Subject: [PATCH 34/41] Update CHANGELOG.md Full UTF-8 support. Update MySQL plugin and web UI to allow storage and display of emojis. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d43f24..74f0218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ##### Removed ##### Fixed - Description-List: Buchstaben in FMS-Kennungen werden nun erkannt und zugelassen [#409](https://github.com/Schrolli91/BOSWatch/issues/409) +- MySQL-Plugin: Volle UTF-8 Kompatibilität für Datenbankstruktur, Verbindung und Darstellung im WebUI [#398](https://github.com/Schrolli91/BOSWatch/issues/398) ##### Security From c113093ee3b9af7e0c5769df9e06ad5954184811 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 27 Mar 2020 09:27:47 +0100 Subject: [PATCH 35/41] Create gpiocontrol.py --- plugins/gpiocontrol/gpiocontrol.py | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 plugins/gpiocontrol/gpiocontrol.py diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py new file mode 100644 index 0000000..32a295d --- /dev/null +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +# Imports + +import RPi.GPIO as GPIO +import time +import threading + +import logging # Global logger +from includes import globalVars # Global variables + +# Helper function, uncomment to use +from includes.helper import timeHandler +from includes.helper import wildcardHandler +from includes.helper import configHandler + +## +# +# 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 + """ + global GPIOPIN + global waitTime + + GPIOPIN = globalVars.config.getint("gpiocontrol","pin") + waitTime = globalVars.config.getint("gpiocontrol","triggertime") + + + GPIO.setmode(GPIO.BCM) + GPIO.setwarnings(False) + GPIO.setup(GPIOPIN, GPIO.OUT) + GPIO.output(GPIOPIN, GPIO.HIGH) + + return + +# +# +# Main function of plugin +# will be called by the alarmHandler +# +def run(typ,freq,data): + try: + if configHandler.checkConfig("gpiocontrol"): #read and debug the config + + logging.debug(globalVars.config.get("gpiocontrol", "pin")) + logging.debug(globalVars.config.get("gpiocontrol", "triggertime")) + logging.debug(globalVars.config.get("gpiocontrol", "activerics")) + + ########## User Plugin CODE ########## + if typ == "FMS": + th = threading.Thread(target = trigger) + th.start() + elif typ == "ZVEI": + th = threading.Thread(target = trigger) + th.start() + elif typ == "POC": + if globalVars.config.get("gpiocontrol", "activerics") == "": + th = threading.Thread(target = trigger) + th.start() + else + if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): + th = threading.Thread(target = trigger) + th.start() + else: + logging.info("Ric not in activerics") + else: + logging.warning("Invalid Typ: %s", typ) + ########## User Plugin CODE ########## + + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) + +def trigger(): + GPIO.output(GPIOPIN, GPIO.LOW) + logging.info("GPIOPIN %s on", GPIOPIN) + time.sleep(waitTime) + GPIO.output(GPIOPIN, GPIO.HIGH) + logging.info("GPIOPIN %s off", GPIOPIN) + + return From f6523929b21c4cbe6ea74487554131d247cfedf7 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 27 Mar 2020 09:31:20 +0100 Subject: [PATCH 36/41] Update gpiocontrol.py --- plugins/gpiocontrol/gpiocontrol.py | 77 ++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index 32a295d..fa52bc6 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -1,6 +1,13 @@ #!/usr/bin/python # -*- coding: UTF-8 -*- +""" + +@author: KS + +@requires: none +""" + # Imports import RPi.GPIO as GPIO @@ -24,18 +31,28 @@ def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() this onLoad() routine is called one time for initialize the plugin + + @requires: nothing + + @return: nothing + @exception: Exception if init has an fatal error so that the plugin couldn't work + """ global GPIOPIN global waitTime - + GPIOPIN = globalVars.config.getint("gpiocontrol","pin") - waitTime = globalVars.config.getint("gpiocontrol","triggertime") - + waitTime = globalVars.config.getint("gpiocontrol","ontime") GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(GPIOPIN, GPIO.OUT) - GPIO.output(GPIOPIN, GPIO.HIGH) + + #GPIO schalten beim START + #GPIO.output(GPIOPIN, GPIO.LOW) + #time.sleep(1) + + GPIO.output(GPIOPIN, GPIO.HIGH) return @@ -45,32 +62,42 @@ def onLoad(): # will be called by the alarmHandler # def run(typ,freq,data): + """ + @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 for dispatch + @type freq: string + @keyword freq: frequency of the SDR Stick + + @requires: If necessary the configuration hast to be set in the config.ini. + + @return: nothing + @exception: nothing, make sure this function will never thrown an exception + """ try: - if configHandler.checkConfig("gpiocontrol"): #read and debug the config + if configHandler.checkConfig("gpiocontrol"): #read and debug the config (let empty if no config used) logging.debug(globalVars.config.get("gpiocontrol", "pin")) - logging.debug(globalVars.config.get("gpiocontrol", "triggertime")) - logging.debug(globalVars.config.get("gpiocontrol", "activerics")) - + logging.debug(globalVars.config.get("gpiocontrol", "ontime")) + ########## User Plugin CODE ########## if typ == "FMS": - th = threading.Thread(target = trigger) - th.start() + #th = threading.Thread(target = trigger) + #th.start() + logging.warning("%s not supported", typ) elif typ == "ZVEI": - th = threading.Thread(target = trigger) - th.start() + #th = threading.Thread(target = trigger) + #th.start() + logging.warning("%s not supported", typ) elif typ == "POC": - if globalVars.config.get("gpiocontrol", "activerics") == "": - th = threading.Thread(target = trigger) - th.start() - else - if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): - th = threading.Thread(target = trigger) - th.start() - else: - logging.info("Ric not in activerics") + if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): + th = threading.Thread(target = trigger) + th.start() + else: + logging.info("Ric not in activerics") else: - logging.warning("Invalid Typ: %s", typ) + logging.warning("Invalid Typ: %s", typ) ########## User Plugin CODE ########## except: @@ -79,9 +106,9 @@ def run(typ,freq,data): def trigger(): GPIO.output(GPIOPIN, GPIO.LOW) - logging.info("GPIOPIN %s on", GPIOPIN) + logging.info("GPIOPIN %s angeschaltet", GPIOPIN) time.sleep(waitTime) - GPIO.output(GPIOPIN, GPIO.HIGH) - logging.info("GPIOPIN %s off", GPIOPIN) + GPIO.output(GPIOPIN, GPIO.HIGH) + logging.info("GPIOPIN %s ausgeschaltet", GPIOPIN) return From bd3e15ba576351b985fbd36af79a5ce80940c522 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 27 Mar 2020 09:34:48 +0100 Subject: [PATCH 37/41] Update gpiocontrol.py --- plugins/gpiocontrol/gpiocontrol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index fa52bc6..c75f072 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -42,7 +42,7 @@ def onLoad(): global waitTime GPIOPIN = globalVars.config.getint("gpiocontrol","pin") - waitTime = globalVars.config.getint("gpiocontrol","ontime") + waitTime = globalVars.config.getint("gpiocontrol","triggertime") GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) @@ -79,7 +79,7 @@ def run(typ,freq,data): if configHandler.checkConfig("gpiocontrol"): #read and debug the config (let empty if no config used) logging.debug(globalVars.config.get("gpiocontrol", "pin")) - logging.debug(globalVars.config.get("gpiocontrol", "ontime")) + logging.debug(globalVars.config.get("gpiocontrol", "triggertime")) ########## User Plugin CODE ########## if typ == "FMS": From e7bd6ae2c5c177cda44d0f113a2d7f08b6ec8b23 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 27 Mar 2020 09:34:54 +0100 Subject: [PATCH 38/41] Update config.template.ini --- config/config.template.ini | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index 9e05679..dd699ee 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -175,6 +175,7 @@ Pushover = 0 Telegram = 0 yowsup = 0 hue = 0 +gpiocontrol = 0 # for developing - template-module template = 0 @@ -463,6 +464,18 @@ 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 +[gpiocontrol] +#Pin that will be triggered +#Only tested on Raspberry Pi 3 +pin = 21 + +#Time the Pin will be triggered (in Seconds) +triggertime = 180 + +#ONLY POC +#POC Rics that trigger PIN (empty: allow all, separator ",") +activerics = 1234567,1234568 + ##################### ##### Not ready yet # ##################### From 6222463a96b4ba6dd03f15e2a157bb3fbf8ccb8f Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 27 Mar 2020 09:38:33 +0100 Subject: [PATCH 39/41] Update gpiocontrol.py --- plugins/gpiocontrol/gpiocontrol.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index c75f072..7662fe8 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -83,19 +83,23 @@ def run(typ,freq,data): ########## User Plugin CODE ########## if typ == "FMS": - #th = threading.Thread(target = trigger) - #th.start() - logging.warning("%s not supported", typ) + th = threading.Thread(target = trigger) + th.start() + #logging.warning("%s not supported", typ) elif typ == "ZVEI": - #th = threading.Thread(target = trigger) - #th.start() - logging.warning("%s not supported", typ) + th = threading.Thread(target = trigger) + th.start() + #logging.warning("%s not supported", typ) elif typ == "POC": - if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): - th = threading.Thread(target = trigger) - th.start() - else: - logging.info("Ric not in activerics") + if globalVars.config.get("gpiocontrol", "activerics") == "": + th = threading.Thread(target = trigger) + th.start() + else + if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): + th = threading.Thread(target = trigger) + th.start() + else: + logging.info("Ric not in activerics") else: logging.warning("Invalid Typ: %s", typ) ########## User Plugin CODE ########## From d4b397073e868ac72916f348b52e81a455fe1b17 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Tue, 14 Apr 2020 10:37:19 +0200 Subject: [PATCH 40/41] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f0218..b1cc352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### __[v2.4.4]__ - unreleased ##### Added - Divera-Plugin: Plugin zum Ansteuern der Divera-Api. [#415](https://github.com/Schrolli91/BOSWatch/pull/415) +- GPIO-Control: Plugin zum Ansteuern der GPIO Pins. [#438](https://github.com/Schrolli91/BOSWatch/pull/438) ##### 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) From b9c6744667aa509dca1024b55f286639287a045f Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 16 Apr 2020 13:10:17 +0200 Subject: [PATCH 41/41] prepare release --- CHANGELOG.md | 5 +---- includes/globalVars.py | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1cc352..d10eb56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -### __[v2.4.4]__ - unreleased +### __[v2.5]__ - 16.04.2020 ##### Added - Divera-Plugin: Plugin zum Ansteuern der Divera-Api. [#415](https://github.com/Schrolli91/BOSWatch/pull/415) - GPIO-Control: Plugin zum Ansteuern der GPIO Pins. [#438](https://github.com/Schrolli91/BOSWatch/pull/438) @@ -8,12 +8,9 @@ - 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) - Pushover-Plugin: Konfigurationsmöglichkeit für den Sound [#418](https://github.com/Schrolli91/BOSWatch/issues/418) -##### Deprecated -##### Removed ##### Fixed - Description-List: Buchstaben in FMS-Kennungen werden nun erkannt und zugelassen [#409](https://github.com/Schrolli91/BOSWatch/issues/409) - MySQL-Plugin: Volle UTF-8 Kompatibilität für Datenbankstruktur, Verbindung und Darstellung im WebUI [#398](https://github.com/Schrolli91/BOSWatch/issues/398) -##### Security ### __[v2.4.3]__ - 22.09.2019 diff --git a/includes/globalVars.py b/includes/globalVars.py index d0edd2a..2133748 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,9 +9,9 @@ Global variables """ # version info -versionNr = "2.4.4" -branch = "dev" -buildDate = "unreleased" +versionNr = "2.5" +branch = "master" +buildDate = "16.04.2020" # Global variables config = 0