From 1eae3098e06c7dbf03ebea5bb540efb73f76a317 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 16:13:06 +0100 Subject: [PATCH 01/31] Add hue plugin --- plugins/hue/hue.py | 122 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 plugins/hue/hue.py diff --git a/plugins/hue/hue.py b/plugins/hue/hue.py new file mode 100644 index 0000000..d01647b --- /dev/null +++ b/plugins/hue/hue.py @@ -0,0 +1,122 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" + +Plugin to control Philips hue lights and switches + +@author: Fabian Kessler + +@requires: none +""" + +# +# Imports +# +import logging # Global logger +from includes import globalVars # Global variables +import json +import requests +import time + +# 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 + @requires: nothing + @return: nothing + @exception: Exception if init has an fatal error so that the plugin couldn't work + """ + try: + ########## User onLoad CODE ########## + pass + ########## User onLoad CODE ########## + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) + raise + +## +# +# Main function of plugin +# will be called by the alarmHandler +# +def run(typ,freq,data): + """ + This function is the implementation of the Plugin. + If necessary the configuration hast to be set in the config.ini. + @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("hue"): #read and debug the config + #for debugging + """logging.debug(globalVars.config.get("hue", "bridgeip")) + logging.debug(globalVars.config.get("hue", "deviceid")) + logging.debug(globalVars.config.get("hue", "apikey")) + logging.debug(globalVars.config.getint("hue", "repeat")) + logging.debug(globalVars.config.getint("hue", "timeon")) + logging.debug(globalVars.config.getint("hue", "timeoff")) + logging.debug(globalVars.config.getint("hue", "keepon"))""" + + ########## User Plugin CODE ########## + if typ == "FMS": + logging.warning("%s not supported", typ) + elif typ == "ZVEI": + logging.warning("%s not supported", typ) + elif typ == "POC": + #logging.warning("%s not supported", typ) + logging.debug("POC received") + bridgeip = globalVars.config.get("hue", "bridgeip") + deviceid = globalVars.config.get("hue", "deviceid") + apikey = globalVars.config.get("hue", "apikey") + repeat = globalVars.config.getint("hue", "repeat") + timeon = globalVars.config.getint("hue", "timeon") + timeoff = globalVars.config.getint("hue", "timeoff") + keepon = globalVars.config.getint("hue", "keepon") + data_on = '{"on":true}' + data_off = '{"on":false}' + url = "http://" + bridgeip + "/api/" + apikey + "/lights/" + deviceid + "/state" + logging.debug("hue REST API URL: %s", url) + + #blinking + for _ in xrange(repeat): + requests.put(url, data=data_on) + logging.debug("on for %s seconds", timeon) + time.sleep(timeon) + requests.put(url, data=data_off) + logging.debug("off for %s seconds", timeoff) + time.sleep(timeoff) + if keepon > 0: + logging.debug("switch to on and wait for keepon to expire") + requests.put(url, data=data_on) + logging.debug("keep on for %s seconds", keepon) + time.sleep(keepon) + requests.put(url, data=data_off) + else: + logging.debug("switch to on and exit plugin") + requests.put(url, data=data_on) + else: + logging.warning("Invalid Typ: %s", typ) + ########## User Plugin CODE ########## + + except: + logging.error("unknown error") +logging.debug("unknown error", exc_info=True) \ No newline at end of file From 04f98f21c4637048d01740df9b8a219ef918e900 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 16:16:21 +0100 Subject: [PATCH 02/31] fix for #375 https://github.com/Schrolli91/BOSWatch/issues/375 --- includes/alarmHandler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 13627fc..06e144b 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -40,7 +40,11 @@ def processAlarmHandler(typ, freq, data): logging.debug("starting processAlarm async") try: from threading import Thread - Thread(target=processAlarm, args=(typ, freq, data)).start() + from copy import deepcopy + dctyp = deepcopy(typ) + dcfreq = deepcopy(freq) + dcdata = deepcopy(data) + Thread(target=processAlarm, args=(dctyp, dcfreq, dcdata)).start() except: logging.error("Error in starting alarm processing async") logging.debug("Error in starting alarm processing async", exc_info=True) From 94321415f57119f4b4cd415b0f1bc808c483f236 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 16:34:05 +0100 Subject: [PATCH 03/31] settings for hue added --- config/config.template.ini | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index e2800ed..f152f0c 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -167,6 +167,7 @@ FFAgent = 0 Pushover = 0 Telegram = 0 yowsup = 0 +hue = 0 # for developing - template-module template = 0 @@ -434,6 +435,26 @@ zvei_message = %DATE% %TIME%: %ZVEI% #Wildcards can be used, see end of the file! poc_message = %MSG% +[hue] +# For API access please read https://www.developers.meethue.com/documentation/getting-started (registration required) +# or https://www.google.com/search?q=philips+hue+how+to+get+api+key +# IP address of the hue bridge +bridgeip = + +# the numeric ID of the device (only one device supported) +deviceid = + +# the authentication string used to access the bridge +apikey = + +# Timing parameters for switching on/off +# Every on/off cycle adds delay to BOSwatch if it operates in synchronous mode. Consider to configure "processAlarmAsync = 1" to activate asynchronous operation in BOSwatch if you switch on/off multiple times. +# If a light bulb is connected, you can keep it blinking for a while +repeat = 2 +timeon = 2 +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 ##################### ##### Not ready yet # From 5fc8f92f4200c37ec070e8e56921c41b20195d59 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 17:04:28 +0100 Subject: [PATCH 04/31] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 852ef54..5b03037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,13 @@ ### __[v#.#]__ - date ##### 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. [#393](https://github.com/Schrolli91/BOSWatch/issues/393) ##### Changed - Telegram-Plugin: Aufrufe der Google API erfolgen per SSL und ohne zusätzliche Bibliotheken [#382](https://github.com/Schrolli91/BOSWatch/pull/382) ##### Deprecated ##### Removed ##### 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() [#375](https://github.com/Schrolli91/BOSWatch/issues/375) ##### Security From 6332bd39a1dcb42d8cd64560c9033ee6a209d7c7 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 17:08:03 +0100 Subject: [PATCH 05/31] description for multicastAlarm RIC updated --- config/config.template.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.template.ini b/config/config.template.ini index f152f0c..04742ca 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -131,7 +131,7 @@ multicastAlarm_ignore_time = 15 # multicastAlarm delimiter RIC (usually used as a starting point for a alarm sequence). Needs to be empty if multicastAlarms are interrupted by normal alarms. multicastAlarm_delimiter_ric = -# multicastAlarm RIC that is used to send the text message +# multicastAlarm RIC (one or more, separated by comma) used to send the text message multicastAlarm_ric = From a360b1cd8ab472276aab5c594025ee944f4ca548 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 20:08:44 +0100 Subject: [PATCH 06/31] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b03037..99c4ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,13 @@ ### __[v#.#]__ - date ##### 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. [#393](https://github.com/Schrolli91/BOSWatch/issues/393) +- 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 - Telegram-Plugin: Aufrufe der Google API erfolgen per SSL und ohne zusätzliche Bibliotheken [#382](https://github.com/Schrolli91/BOSWatch/pull/382) ##### Deprecated ##### Removed ##### 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() [#375](https://github.com/Schrolli91/BOSWatch/issues/375) +- 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) ##### Security From f86aeb914b09cb6ec4f4ea78a9e7d7b33c202861 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 3 Mar 2019 20:38:43 +0100 Subject: [PATCH 07/31] Update alarmHandler.py --- includes/alarmHandler.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 06e144b..38724a8 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -14,6 +14,7 @@ import logging # Global logger import time # timestamp from includes import globalVars # Global variables +from copy import deepcopy ## # @@ -36,20 +37,20 @@ def processAlarmHandler(typ, freq, data): @return: nothing @exception: Exception if starting a Thread failed """ + #copy objects to avoid issues if the objects will be changed by plugin's or during asynch/threaded processing + dctyp = deepcopy(typ) + dcfreq = deepcopy(freq) + dcdata = deepcopy(data) if globalVars.config.getboolean("BOSWatch","processAlarmAsync") == True: logging.debug("starting processAlarm async") try: from threading import Thread - from copy import deepcopy - dctyp = deepcopy(typ) - dcfreq = deepcopy(freq) - dcdata = deepcopy(data) Thread(target=processAlarm, args=(dctyp, dcfreq, dcdata)).start() except: logging.error("Error in starting alarm processing async") logging.debug("Error in starting alarm processing async", exc_info=True) else: - processAlarm(typ, freq, data) + processAlarm(dctyp, dcfreq, dcdata) ## From ea68fabc12e28d634995c6ba4a72c6d1eccf877a Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 14 Mar 2019 11:41:38 +0100 Subject: [PATCH 08/31] logging fixed --- plugins/hue/hue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hue/hue.py b/plugins/hue/hue.py index d01647b..87f74bb 100644 --- a/plugins/hue/hue.py +++ b/plugins/hue/hue.py @@ -119,4 +119,4 @@ def run(typ,freq,data): except: logging.error("unknown error") -logging.debug("unknown error", exc_info=True) \ No newline at end of file + logging.debug("unknown error", exc_info=True) From b3e63afc9ce0c34091fa0813da3114d227b6df89 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 14 Mar 2019 12:02:00 +0100 Subject: [PATCH 09/31] deepcopy of alarm data moved to processAlarm --- includes/alarmHandler.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 38724a8..3cff661 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -37,20 +37,16 @@ def processAlarmHandler(typ, freq, data): @return: nothing @exception: Exception if starting a Thread failed """ - #copy objects to avoid issues if the objects will be changed by plugin's or during asynch/threaded processing - dctyp = deepcopy(typ) - dcfreq = deepcopy(freq) - dcdata = deepcopy(data) if globalVars.config.getboolean("BOSWatch","processAlarmAsync") == True: logging.debug("starting processAlarm async") try: from threading import Thread - Thread(target=processAlarm, args=(dctyp, dcfreq, dcdata)).start() + Thread(target=processAlarm, args=(typ, freq, data)).start() except: logging.error("Error in starting alarm processing async") logging.debug("Error in starting alarm processing async", exc_info=True) else: - processAlarm(dctyp, dcfreq, dcdata) + processAlarm(typ, freq, data) ## @@ -77,15 +73,19 @@ def processAlarm(typ, freq, data): logging.debug("[ ALARM ]") # timestamp, to make sure, that all plugins use the same time data['timestamp'] = int(time.time()) + #copy objects to avoid issues if the objects will be changed by the plugin's during runtime or during asynch/threaded processing + dctyp = deepcopy(typ) + dcfreq = deepcopy(freq) + dcdata = deepcopy(data) # Go to all plugins in pluginList for pluginName, plugin in globalVars.pluginList.items(): # if enabled use RegEx-filter if globalVars.config.getint("BOSWatch","useRegExFilter"): from includes import regexFilter - if regexFilter.checkFilters(typ, data, pluginName, freq): + if regexFilter.checkFilters(dctyp, dcdata, pluginName, dcfreq): logging.debug("call Plugin: %s", pluginName) try: - plugin.run(typ, freq, data) + plugin.run(dctyp, dcfreq, dcdata) logging.debug("return from: %s", pluginName) except: # call next plugin, if one has thrown an exception @@ -93,7 +93,7 @@ def processAlarm(typ, freq, data): else: # RegEX filter off - call plugin directly logging.debug("call Plugin: %s", pluginName) try: - plugin.run(typ, freq, data) + plugin.run(dctyp, dcfreq, dcdata) logging.debug("return from: %s", pluginName) except: # call next plugin, if one has thrown an exception From 07a69d5e26514ce06cc9f1ead049e72970e4d0c4 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 14 Mar 2019 12:04:35 +0100 Subject: [PATCH 10/31] comment updated --- includes/alarmHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 3cff661..98998e0 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -73,7 +73,7 @@ def processAlarm(typ, freq, data): logging.debug("[ ALARM ]") # timestamp, to make sure, that all plugins use the same time data['timestamp'] = int(time.time()) - #copy objects to avoid issues if the objects will be changed by the plugin's during runtime or during asynch/threaded processing + # copy objects to avoid issues if the objects will be changed by the plugin's during runtime and during asynch/threaded processing dctyp = deepcopy(typ) dcfreq = deepcopy(freq) dcdata = deepcopy(data) From b1170668b216c79716d09e10d8b1269fec157389 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 14 Mar 2019 12:07:32 +0100 Subject: [PATCH 11/31] moved copy into for loop --- includes/alarmHandler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 98998e0..92a80db 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -73,12 +73,12 @@ def processAlarm(typ, freq, data): logging.debug("[ ALARM ]") # timestamp, to make sure, that all plugins use the same time data['timestamp'] = int(time.time()) - # copy objects to avoid issues if the objects will be changed by the plugin's during runtime and during asynch/threaded processing - dctyp = deepcopy(typ) - dcfreq = deepcopy(freq) - dcdata = deepcopy(data) # Go to all plugins in pluginList for pluginName, plugin in globalVars.pluginList.items(): + # copy objects to avoid issues if the objects will be changed by the plugin's during runtime and during asynch/threaded processing + dctyp = deepcopy(typ) + dcfreq = deepcopy(freq) + dcdata = deepcopy(data) # if enabled use RegEx-filter if globalVars.config.getint("BOSWatch","useRegExFilter"): from includes import regexFilter From af887c2b23ce3b8eab0778c441d43f39b3dcf586 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 25 Apr 2019 21:35:21 +0200 Subject: [PATCH 12/31] enhancement for deepcopy --- includes/alarmHandler.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 92a80db..95b6cf0 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -14,7 +14,7 @@ import logging # Global logger import time # timestamp from includes import globalVars # Global variables -from copy import deepcopy +from copy import deepcopy # copy objects to avoid issues if the objects will be changed by the plugin's during runtime and during asynch/threaded processing ## # @@ -41,7 +41,7 @@ def processAlarmHandler(typ, freq, data): logging.debug("starting processAlarm async") try: from threading import Thread - Thread(target=processAlarm, args=(typ, freq, data)).start() + Thread(target=processAlarm, args=(typ, freq, deepcopy(data))).start() except: logging.error("Error in starting alarm processing async") logging.debug("Error in starting alarm processing async", exc_info=True) @@ -75,17 +75,13 @@ def processAlarm(typ, freq, data): data['timestamp'] = int(time.time()) # Go to all plugins in pluginList for pluginName, plugin in globalVars.pluginList.items(): - # copy objects to avoid issues if the objects will be changed by the plugin's during runtime and during asynch/threaded processing - dctyp = deepcopy(typ) - dcfreq = deepcopy(freq) - dcdata = deepcopy(data) # if enabled use RegEx-filter if globalVars.config.getint("BOSWatch","useRegExFilter"): from includes import regexFilter - if regexFilter.checkFilters(dctyp, dcdata, pluginName, dcfreq): + if regexFilter.checkFilters(typ, data, pluginName, freq): logging.debug("call Plugin: %s", pluginName) try: - plugin.run(dctyp, dcfreq, dcdata) + plugin.run(typ, freq, deepcopy(data)) logging.debug("return from: %s", pluginName) except: # call next plugin, if one has thrown an exception @@ -93,7 +89,7 @@ def processAlarm(typ, freq, data): else: # RegEX filter off - call plugin directly logging.debug("call Plugin: %s", pluginName) try: - plugin.run(dctyp, dcfreq, dcdata) + plugin.run(typ, freq, deepcopy(data)) logging.debug("return from: %s", pluginName) except: # call next plugin, if one has thrown an exception From f4c35391b4f80b9dec2037c2cf413639348c3231 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Thu, 1 Aug 2019 22:20:35 +0200 Subject: [PATCH 13/31] Update FFAgent.py Added a OrderedDict to keep the Content-Type first in a URL Request to prevent HTTP 500 Errors from the FF-Agent API. --- plugins/FFAgent/FFAgent.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 561ca86..52cae9c 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -12,6 +12,7 @@ FFAgent-Plugin to send FMS-, ZVEI- and POCSAG - messages to FF-Agent import logging # Global logger import hmac, hashlib import json, requests +import collections from includes import globalVars # Global variables @@ -134,6 +135,15 @@ def run(typ,freq,data): } logging.debug(alarmHeaders) + alarmHeaders = collections.OrderedDict(alarmHeaders) + alarmHeadersOrdered = collections.OrderedDict() + alarmHeadersOrdered["Content-Type"]=alarmHeaders["Content-Type"] + alarmHeadersOrdered["webApiToken"]=alarmHeaders["webApiToken"] + alarmHeadersOrdered["accessToken"]=alarmHeaders["accessToken"] + alarmHeadersOrdered["selectiveCallCode"]=alarmHeaders["selectiveCallCode"] + alarmHeadersOrdered["hmac"]=alarmHeaders["hmac"] + logging.debug(alarmHeadersOrdered) + if globalVars.config.get("FFAgent", "live") == "1": r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: From 190e7f36feb0f2137f731d08178b05a9612b1411 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Sat, 3 Aug 2019 10:27:45 +0200 Subject: [PATCH 14/31] Update FFAgent.py Used json.dumps for the alarmHeaders instead of a OrderedDict to preserve Insertion Order --- plugins/FFAgent/FFAgent.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 52cae9c..bd3b949 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -12,7 +12,6 @@ FFAgent-Plugin to send FMS-, ZVEI- and POCSAG - messages to FF-Agent import logging # Global logger import hmac, hashlib import json, requests -import collections from includes import globalVars # Global variables @@ -126,24 +125,15 @@ def run(typ,freq,data): alarmData = json.dumps(alarmData) logging.debug(alarmData) - alarmHeaders = { + alarmHeaders = json.dumps({ "Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() - } + }) logging.debug(alarmHeaders) - alarmHeaders = collections.OrderedDict(alarmHeaders) - alarmHeadersOrdered = collections.OrderedDict() - alarmHeadersOrdered["Content-Type"]=alarmHeaders["Content-Type"] - alarmHeadersOrdered["webApiToken"]=alarmHeaders["webApiToken"] - alarmHeadersOrdered["accessToken"]=alarmHeaders["accessToken"] - alarmHeadersOrdered["selectiveCallCode"]=alarmHeaders["selectiveCallCode"] - alarmHeadersOrdered["hmac"]=alarmHeaders["hmac"] - logging.debug(alarmHeadersOrdered) - if globalVars.config.get("FFAgent", "live") == "1": r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: From bd5f7f4707c982d07882495dc8d75273d5b008e4 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Mon, 19 Aug 2019 10:12:25 +0200 Subject: [PATCH 15/31] Update FFAgent.py Passing the Headers directly instead of a Dict to prevent "reordering" with Python <3.7. --- plugins/FFAgent/FFAgent.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index bd3b949..9b4c74c 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -124,20 +124,20 @@ def run(typ,freq,data): alarmData = json.dumps(alarmData) logging.debug(alarmData) - - alarmHeaders = json.dumps({ + + alarmHeaders = { "Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() - }) + } logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1": - r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) + r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: - r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile) + r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile) except: logging.error("cannot send FFAgent request") From e2ed799b8768ef957ef5443a87b35b7793519341 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Mon, 19 Aug 2019 11:10:56 +0200 Subject: [PATCH 16/31] Update FFAgent.py Added some additional Debug Logging --- plugins/FFAgent/FFAgent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 9b4c74c..a6d8b79 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -138,6 +138,8 @@ def run(typ,freq,data): r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile) + + logging.debug(r) except: logging.error("cannot send FFAgent request") From 8599093a6c0e67409997733d0d7868187973287d Mon Sep 17 00:00:00 2001 From: CJHarms Date: Tue, 20 Aug 2019 10:27:46 +0200 Subject: [PATCH 17/31] Update FFAgent.py Replaced Double Quotes with Single Quotes in the HTTP Request --- plugins/FFAgent/FFAgent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index a6d8b79..028b80a 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -135,11 +135,11 @@ def run(typ,freq,data): logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1": - r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) + r = requests.post(url, data=alarmData, headers={'Content-Type': 'application/json', 'webApiToken': webApiToken, 'accessToken': accessToken, 'selectiveCallCode': selectiveCallCode, 'hmac': hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: - r = requests.post(url, data=alarmData, headers={"Content-Type": "application/json", "webApiToken": webApiToken, "accessToken": accessToken, "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile) + r = requests.post(url, data=alarmData, headers={'Content-Type': 'application/json', 'webApiToken': webApiToken, 'accessToken': accessToken, 'selectiveCallCode': selectiveCallCode, 'hmac': hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile) - logging.debug(r) + logging.debug(response.content) except: logging.error("cannot send FFAgent request") From 42f841ba15b274abc3f8108d91dd9b4918e5bf94 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Wed, 28 Aug 2019 09:06:44 +0200 Subject: [PATCH 18/31] Update FFAgent.py Fixed Header Ordering by using Requests Session. Additionally added some Debug Logging. --- plugins/FFAgent/FFAgent.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 028b80a..7ab8a92 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -13,6 +13,8 @@ import logging # Global logger import hmac, hashlib import json, requests +from collections import OrderedDict + from includes import globalVars # Global variables #from includes.helper import timeHandler @@ -123,6 +125,7 @@ def run(typ,freq,data): } alarmData = json.dumps(alarmData) + logging.debug(alarmData) alarmHeaders = { @@ -132,14 +135,30 @@ def run(typ,freq,data): "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() } + logging.debug(alarmHeaders) - if globalVars.config.get("FFAgent", "live") == "1": - r = requests.post(url, data=alarmData, headers={'Content-Type': 'application/json', 'webApiToken': webApiToken, 'accessToken': accessToken, 'selectiveCallCode': selectiveCallCode, 'hmac': hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) - else: - r = requests.post(url, data=alarmData, headers={'Content-Type': 'application/json', 'webApiToken': webApiToken, 'accessToken': accessToken, 'selectiveCallCode': selectiveCallCode, 'hmac': hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()}, verify=serverCertFile) + alarmHeadersOrdered=OrderedDict() + alarmHeadersOrdered['webApiToken']=webApiToken + alarmHeadersOrdered['accessToken']=accessToken + alarmHeadersOrdered['selectiveCallCode']=selectiveCallCode + alarmHeadersOrdered['hmac']=hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() - logging.debug(response.content) + logging.debug(alarmHeadersOrdered) + + if globalVars.config.get("FFAgent", "live") == "1": + s = requests.Session() + s.headers = OrderedDict([('Content-Type', 'application/json')]) + logging.debug(s.headers) + r = s.post(url, data=alarmData, headers=alarmHeadersOrdered, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) + + else: + s = requests.Session() + s.headers = OrderedDict([('Content-Type', 'application/json')]) + logging.debug(s.headers) + r = s.post(url, data=alarmData, headers=alarmHeadersOrdered, verify=serverCertFile) + + logging.debug(r.request.headers) except: logging.error("cannot send FFAgent request") From 483c4f167ea6794da23f371cd2873395d3d0654d Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 28 Aug 2019 11:09:01 +0200 Subject: [PATCH 19/31] Update globalVars.py --- includes/globalVars.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/globalVars.py b/includes/globalVars.py index d12aff4..52c57ff 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,9 +9,9 @@ Global variables """ # version info -versionNr = "2.4.2" -branch = "master" -buildDate = "11.03.2019" +versionNr = "2.4.3" +branch = "dev" +buildDate = "unreleased" # Global variables config = 0 From ae11c53fe646867a9b3819db906eebea810d9eb7 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Wed, 28 Aug 2019 11:16:17 +0200 Subject: [PATCH 20/31] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FF Agent Fixes dokumentiert und dem Changelog hinzugefügt. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb0f5e..dc5f34a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - 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) ##### Deprecated ##### Removed ##### Fixed From 52fe249ab66973a1a01700763e0ca98dc6c4bd65 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 5 Sep 2019 08:26:24 +0200 Subject: [PATCH 21/31] Filtering for geo-data instead of checking for locations in a specific plugin, a central approach is done here; at the moment, a regex containing coordinates is to be found in the poc-text. The coordinates are parsed and afterwards stored into data as lon/lat. --- includes/decoders/poc.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 30a0e22..9c53cbc 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -124,6 +124,19 @@ def decode(freq, decoded): if "Alpha:" in decoded: #check if there is a text message poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() + logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) + m = re.search(globalVars.config.get("POC","geo_format"),poc_text) + if m: + has_geo = True + geo_order = globalVars.config.get("POC","geo_order").split(',') + if geo_order[0].lower == "lon": + lat = m.group(1) + "." + m.group(2) + lon = m.group(3) + "." + m.group(4) + else: + lon = m.group(1) + "." + m.group(2) + lat = m.group(3) + "." + m.group(4) + else: + has_geo = False else: poc_text = "" @@ -132,7 +145,10 @@ def decode(freq, decoded): # check for double alarm if doubleFilter.checkID("POC", poc_id+poc_sub, poc_text): - data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id} + data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id, "has_geo":has_geo} + if has_geo == True: + data["lon"] = lon + data["lat"] = lat # Add function as character a-d to dataset data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") From 33b633c475a49b4a0ef57b282a7549df1006fae6 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 5 Sep 2019 08:27:44 +0200 Subject: [PATCH 22/31] Update config.template.ini Performing changes to provide regex for searching coordinates in poc-text --- config/config.template.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index 04742ca..a8806c6 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -115,6 +115,10 @@ netIdent_ric = 0174760, 1398098 # you can hold one entry per netIdent_ric [0] or the whole history [1] netIdent_history = 0 +# If a RIC contains coordinates, specify the regex used to decode them +geo_format = #C(\d{2})(\d{5}),(\d{2})(\d{5})# +geo_order = LON, lon, LAT, lat + [multicastAlarm] # Configure multicastAlarm if your POCSAG network uses an optimized transmission scheme for alarms with more than one RIC (often found in Swissphone networks). From ad0673b3577cb376e430359f4aa0fd48085f9a35 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 5 Sep 2019 08:29:57 +0200 Subject: [PATCH 23/31] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc5f34a..8d55877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### __[v2.#]__ - 05.09.2019 +##### Added +##### Changed +- 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. +##### Deprecated +##### Removed +##### Fixed +##### Security ### __[v#.#]__ - date ##### Added From 7decb88d8bb7ad7f48b558ee1b5c12111c1b67be Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 7 Sep 2019 13:41:19 +0200 Subject: [PATCH 24/31] Update CHANGELOG.md --- CHANGELOG.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d55877..097f8f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,6 @@ # Changelog -### __[v2.#]__ - 05.09.2019 -##### Added -##### Changed -- 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. -##### Deprecated -##### Removed -##### Fixed -##### Security + ### __[v#.#]__ - date ##### Added @@ -21,6 +14,14 @@ - 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) ##### Security +### __[v2.#]__ - 05.09.2019 +##### Added +##### Changed +- 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. +##### Deprecated +##### Removed +##### Fixed +##### Security ### __[v2.4.2]__ - 11.03.2019 ##### Added From dab072d03c9d4ee1554de0b1990e23c3e9ca4308 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 7 Sep 2019 22:12:58 +0200 Subject: [PATCH 25/31] Update CHANGELOG.md --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 097f8f3..57fccaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog - +### __[v#.#]_ - date +##### Added +##### Changed +##### Deprecated +##### Removed +##### Fixed +##### Security ### __[v#.#]__ - date @@ -8,20 +14,14 @@ - 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. ##### Deprecated ##### Removed ##### 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) ##### Security -### __[v2.#]__ - 05.09.2019 -##### Added -##### Changed -- 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. -##### Deprecated -##### Removed -##### Fixed -##### Security + ### __[v2.4.2]__ - 11.03.2019 ##### Added From 6130efa76215cd4855e4cb1be66960dd8d74822b Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 7 Sep 2019 22:57:04 +0200 Subject: [PATCH 26/31] Update poc.py Exceptionhandling in case no regex is specified --- includes/decoders/poc.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 9c53cbc..65f29d0 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -123,22 +123,29 @@ def decode(freq, decoded): logging.debug("POCSAG Bitrate: %s", bitrate) if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() - logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) - m = re.search(globalVars.config.get("POC","geo_format"),poc_text) - if m: - has_geo = True - geo_order = globalVars.config.get("POC","geo_order").split(',') - if geo_order[0].lower == "lon": - lat = m.group(1) + "." + m.group(2) - lon = m.group(3) + "." + m.group(4) - else: - lon = m.group(1) + "." + m.group(2) - lat = m.group(3) + "." + m.group(4) - else: - has_geo = False - else: - poc_text = "" + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() + try: + logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) + m = re.search(globalVars.config.get("POC","geo_format"),poc_text) + if m: + logging.debug("Found geo-tag in message, parsing...") + has_geo = True + geo_order = globalVars.config.get("POC","geo_order").split(',') + if geo_order[0].lower == "lon": + lat = m.group(1) + "." + m.group(2) + lon = m.group(3) + "." + m.group(4) + else: + lon = m.group(1) + "." + m.group(2) + lat = m.group(3) + "." + m.group(4) + logging.debug("Finished parsing geo; lon: %s, lat: %s", lon, lat) + else: + logging.debug("No geo-tag found") + has_geo = False + except: + logging.error("Exception caused by searching for geo-tag") + has_geo = False + else: + poc_text = "" if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid if isAllowed(poc_id): From 9d8c9c986cad4dd5e2fe922a100926830dd38b9b Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 8 Sep 2019 18:14:24 +0200 Subject: [PATCH 27/31] edit changelog --- CHANGELOG.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57fccaf..3629d7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,4 @@ # Changelog -### __[v#.#]_ - date -##### Added -##### Changed -##### Deprecated -##### Removed -##### Fixed -##### Security ### __[v#.#]__ - date @@ -22,7 +15,6 @@ ##### Security - ### __[v2.4.2]__ - 11.03.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 216ee05f183224429d3beab16ad95f2d20029f3f Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 21 Sep 2019 00:32:52 +0200 Subject: [PATCH 28/31] Update config.template.ini Implementing global switch to enable geo-decoding --- config/config.template.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index a8806c6..9e05679 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -115,6 +115,9 @@ netIdent_ric = 0174760, 1398098 # you can hold one entry per netIdent_ric [0] or the whole history [1] netIdent_history = 0 +# With some message, coordinates can be sent to determine the destination +# Do you want to enable this feature? (0 - off | 1 - on) +geo_enable = 0 # If a RIC contains coordinates, specify the regex used to decode them geo_format = #C(\d{2})(\d{5}),(\d{2})(\d{5})# geo_order = LON, lon, LAT, lat From 0c19b5ece5b0a645607d0ecb9187881622514584 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 21 Sep 2019 00:35:28 +0200 Subject: [PATCH 29/31] Update poc.py Switch to enable decoding --- includes/decoders/poc.py | 50 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 65f29d0..5389041 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -123,30 +123,32 @@ def decode(freq, decoded): logging.debug("POCSAG Bitrate: %s", bitrate) if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() - try: - logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) - m = re.search(globalVars.config.get("POC","geo_format"),poc_text) - if m: - logging.debug("Found geo-tag in message, parsing...") - has_geo = True - geo_order = globalVars.config.get("POC","geo_order").split(',') - if geo_order[0].lower == "lon": - lat = m.group(1) + "." + m.group(2) - lon = m.group(3) + "." + m.group(4) - else: - lon = m.group(1) + "." + m.group(2) - lat = m.group(3) + "." + m.group(4) - logging.debug("Finished parsing geo; lon: %s, lat: %s", lon, lat) - else: - logging.debug("No geo-tag found") - has_geo = False - except: - logging.error("Exception caused by searching for geo-tag") - has_geo = False - else: - poc_text = "" - + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').repl$ + if globalVars.config.getint("POC","geo_enable"): + try: + logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),$ + m = re.search(globalVars.config.get("POC","geo_format"),poc_text) + if m: + logging.debug("Found geo-tag in message, parsing...") + has_geo = True + geo_order = globalVars.config.get("POC","geo_order").split(',') + if geo_order[0].lower == "lon": + lat = m.group(1) + "." + m.group(2) + lon = m.group(3) + "." + m.group(4) + else: + lon = m.group(1) + "." + m.group(2) + lat = m.group(3) + "." + m.group(4) + logging.debug("Finished parsing geo; lon: %s, lat: %s", lon, lat) + else: + logging.debug("No geo-tag found") + has_geo = False + except: + has_geo = False + logging.error("Exception parsing geo-information",exc_info=true) + else: + has_geo = False + else: + poc_text = "" if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid if isAllowed(poc_id): From d45214627a3a887122fd0df67ddd5010a473c810 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 21 Sep 2019 23:50:46 +0200 Subject: [PATCH 30/31] Update poc.py Fixing brokes line-ends --- includes/decoders/poc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 5389041..6ab9aa0 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -123,10 +123,10 @@ def decode(freq, decoded): logging.debug("POCSAG Bitrate: %s", bitrate) if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').repl$ + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() if globalVars.config.getint("POC","geo_enable"): try: - logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),$ + logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) m = re.search(globalVars.config.get("POC","geo_format"),poc_text) if m: logging.debug("Found geo-tag in message, parsing...") From dd82fe80abff435f7ba92980ad83bdd569a0b975 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 22 Sep 2019 09:42:15 +0200 Subject: [PATCH 31/31] prepare for release --- CHANGELOG.md | 5 +---- includes/globalVars.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3629d7a..ab81cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,15 @@ # Changelog -### __[v#.#]__ - date +### __[v2.4.3]__ - 22.09.1991 ##### 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) ##### 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. -##### Deprecated -##### Removed ##### 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) -##### Security ### __[v2.4.2]__ - 11.03.2019 diff --git a/includes/globalVars.py b/includes/globalVars.py index 52c57ff..3f197cb 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -10,8 +10,8 @@ Global variables # version info versionNr = "2.4.3" -branch = "dev" -buildDate = "unreleased" +branch = "master" +buildDate = "22.09.2019" # Global variables config = 0