From 04af8f03597e1e15a6a4e012aa8680a2288471d7 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 28 Apr 2020 13:02:26 +0200 Subject: [PATCH 01/47] prep for next rel --- CHANGELOG.md | 13 +++++++++---- includes/globalVars.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1efabf1..3c7787ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,21 @@ # Changelog -### __[v2.5.1]__ - unreleased +### __[v2.5.2]__ - unreleased ##### Added -- Plugin requirements: Added requirements.txt for all plugins requiring extra python packages so the install will be easier -- DescriptionList POC: add new description parameter for Sub-RICs without a main RIC definition. parameter 'onlysubric'. [#449](https://github.com/Schrolli91/BOSWatch/pull/449) ##### Changed ##### Deprecated ##### Removed ##### Fixed +##### Security + + +### __[v2.5.1]__ - 28.04.2020 +##### Added +- Plugin requirements: Added requirements.txt for all plugins requiring extra python packages so the install will be easier +- DescriptionList POC: add new description parameter for Sub-RICs without a main RIC definition. parameter 'onlysubric'. [#449](https://github.com/Schrolli91/BOSWatch/pull/449) +##### Fixed - MySQL plugin: Ensure character set (utf8mb4) and collation (utf8mb4_general_ci) are set correctly when connection to database is established. [#447](https://github.com/Schrolli91/BOSWatch/pull/447) - E-Mail plugin: Create MIME-compliant header that can contain any kind of string. [#448](https://github.com/Schrolli91/BOSWatch/pull/448) -##### Security ### __[v2.5]__ - 16.04.2020 diff --git a/includes/globalVars.py b/includes/globalVars.py index 0a8045ce..b0b50fb7 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,7 +9,7 @@ """ # version info -versionNr = "2.5.1" +versionNr = "2.5.2" branch = "dev" buildDate = "unreleased" From 0bfd6d558c75b10dab768913cbaa37f71ea36d0b Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 28 Apr 2020 13:04:43 +0200 Subject: [PATCH 02/47] fix CL --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7787ef..02a44a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ ### __[v2.5.1]__ - 28.04.2020 ##### Added -- Plugin requirements: Added requirements.txt for all plugins requiring extra python packages so the install will be easier +- Plugin requirements: Added requirements.txt for all plugins requiring extra python packages so the install will be easier [#446](https://github.com/Schrolli91/BOSWatch/pull/446) - DescriptionList POC: add new description parameter for Sub-RICs without a main RIC definition. parameter 'onlysubric'. [#449](https://github.com/Schrolli91/BOSWatch/pull/449) ##### Fixed - MySQL plugin: Ensure character set (utf8mb4) and collation (utf8mb4_general_ci) are set correctly when connection to database is established. [#447](https://github.com/Schrolli91/BOSWatch/pull/447) From 6580d385f83c1408d909de2d3f397b1cf24e2294 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 28 Apr 2020 13:14:22 +0200 Subject: [PATCH 03/47] update readme BW3 hint --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f4ed231..829bfdcf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The software was developed using the Multimon-NG code, a function in the real op ### Fast support on https://bwcc.boswatch.de (Mattermost) -##### Work on BOSWatch 3 has started +### BW3 in first testing phase - see: https://github.com/BOSWatch/BW3-Core |Branch|Code Qualität|CI-Build| |---|---|---| From 572c40d1a475776c639de84bd7124d3dd9487f7b Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Wed, 29 Apr 2020 19:50:45 +0200 Subject: [PATCH 04/47] Add vehicle / ric to Divera Plugin --- config/config.template.ini | 3 +++ plugins/Divera/Divera.py | 54 +++++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index af5da011..ffedcef4 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -494,17 +494,20 @@ SubD = poc_title = %DESCR%: %MSG% poc_text = %DATE% %TIME% - %DESCR%: %MSG% +poc_ric = %DESCR% # Section for ZVEI # default prio for all ZVEI - except you specify it different zvei_prio = true zvei_title = Alarm: %ZVEI% zvei_text = %DATE% %TIME%: %ZVEI% +zvei_ric = %DESCR% # Section for FMS fms_prio = true fms_title = FMS: %FMS% fms_text = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR% +fms_vehicle = %DESCR% [gpiocontrol] diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 60092ed5..b6861daa 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -61,6 +61,7 @@ def run(typ, freq, data): text = globalVars.config.get("Divera", "fms_text") title = globalVars.config.get("Divera", "fms_title") priority = globalVars.config.get("Divera", "fms_prio") + vehicle = globalVars.config.get("Divera", "fms_vehicle") elif typ == "ZVEI": # @@ -69,6 +70,7 @@ def run(typ, freq, data): text = globalVars.config.get("Divera", "zvei_text") title = globalVars.config.get("Divera", "zvei_title") priority = globalVars.config.get("Divera","zvei_std_prio") + ric = globalVars.config.get("Divera","zvei_ric") elif typ == "POC": # @@ -87,6 +89,7 @@ def run(typ, freq, data): text = globalVars.config.get("Divera", "poc_text") title = globalVars.config.get("Divera", "poc_title") + ric = globalVars.config.get("Divera", "poc_ric") else: logging.warning("Invalid type: %s", typ) @@ -101,9 +104,18 @@ def run(typ, freq, data): # replace the wildcards text = wildcardHandler.replaceWildcards(text, data) title = wildcardHandler.replaceWildcards(title, data) + if typ == "FMS": + vehicle = wildcardHandler.replaceWildcards(vehicle, data) + else: + ric = wildcardHandler.replaceWildcards(ric, data) + # Logging data to send logging.debug("Title : %s", title) + if typ == "FMS": + logging.debug("Vehicle : %s", vehicle) + else: + logging.debug("RIC : %s", ric) logging.debug("Text : %s", text) logging.debug("Priority: %s", priority) @@ -112,15 +124,39 @@ def run(typ, freq, data): logging.info("No Priority set for type '%s'! Skipping Divera-Alarm!", typ) return - # start the connection - conn = httplib.HTTPSConnection("www.divera247.com:443") - conn.request("GET", "/api/alarm", - urllib.urlencode({ - "accesskey": globalVars.config.get("Divera", "accesskey"), - "title": title, - "text": text, - "priority": priority, - })) + # Check FMS + if typ == "FMS": + if (vehicle == ''): + logging.info("No Vehicle set!"); + + else: + if (ric == ''): + logging.info("No RIC set!"); + + # start connection to Divera + if typ == "FMS": + # start the connection FMS + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/fms", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "vehicle_ric": vehicle, + "title": title, + "text": text, + "priority": priority, + })) + + else: + # start connection ZVEI / POC + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/alarm", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "title": title, + "ric": ric, + "text": text, + "priority": priority, + })) except: logging.error("cannot send Divera request") From cf70393b2fe35facdca1fbcecd7b234e673214be Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Wed, 29 Apr 2020 19:57:44 +0200 Subject: [PATCH 05/47] remove std from divera plugin in zvei --- plugins/Divera/Divera.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index b6861daa..0b4b1d5b 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -69,7 +69,7 @@ def run(typ, freq, data): # text = globalVars.config.get("Divera", "zvei_text") title = globalVars.config.get("Divera", "zvei_title") - priority = globalVars.config.get("Divera","zvei_std_prio") + priority = globalVars.config.get("Divera","zvei_prio") ric = globalVars.config.get("Divera","zvei_ric") elif typ == "POC": From fd2392437f8511df9b409d8f858ad696a5d1c0d3 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Wed, 29 Apr 2020 20:01:37 +0200 Subject: [PATCH 06/47] add notice for zvei_ric at 6 characters --- config/config.template.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.template.ini b/config/config.template.ini index ffedcef4..80ac8c5d 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -501,6 +501,7 @@ poc_ric = %DESCR% zvei_prio = true zvei_title = Alarm: %ZVEI% zvei_text = %DATE% %TIME%: %ZVEI% +# zvei_ric working at 6 characters or more zvei_ric = %DESCR% # Section for FMS From 2a3243477cedef0a2cc7000d89e3f1a06f775e34 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Wed, 29 Apr 2020 20:49:07 +0200 Subject: [PATCH 07/47] FMS: add status_id/status_note; POC: add netfilter --- plugins/Divera/Divera.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 0b4b1d5b..6ce090e2 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -16,6 +16,24 @@ from includes.helper import configHandler from includes.helper import wildcardHandler +def isSignal(poc_id): + """ + @type poc_id: string + @param poc_id: POCSAG Ric + + @requires: Configuration has to be set in the config.ini + + @return: True if the Ric is Signal, other False + @exception: none + """ + # If RIC is Signal return True, else False + if globalVars.config.get("POC", "netIdent_ric"): + if poc_id in globalVars.config.get("POC", "netIdent_ric"): + logging.info("RIC %s is net ident", poc_id) + return True + else: + logging.info("RIC %s is no net ident", poc_id) + return False ## # @@ -141,13 +159,15 @@ def run(typ, freq, data): urllib.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), "vehicle_ric": vehicle, + "status_id": data["status"], + "status_note": data["directionText"], "title": title, "text": text, "priority": priority, })) - else: - # start connection ZVEI / POC + elif typ == "ZVEI": + # start connection POC conn = httplib.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/alarm", urllib.urlencode({ @@ -157,6 +177,19 @@ def run(typ, freq, data): "text": text, "priority": priority, })) + + elif typ == "POC": + if isSignal(data["ric"]): + # start connection POC + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/alarm", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "title": title, + "ric": ric, + "text": text, + "priority": priority, + })) except: logging.error("cannot send Divera request") From 8eb2901bcb4ff4e26412d9ceda03b500edad7d8c Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Thu, 30 Apr 2020 23:48:13 +0200 Subject: [PATCH 08/47] Add logging information --- plugins/Divera/Divera.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 6ce090e2..9759e5e2 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -190,6 +190,13 @@ def run(typ, freq, data): "text": text, "priority": priority, })) + + else: + logging.debug("RIC is net ident") + + else: + loggin.debug("No Type is set", exc_info=True) + return except: logging.error("cannot send Divera request") From 18358abec20604c9dd5e0ce41a5f9f029dce30f1 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Thu, 30 Apr 2020 23:49:20 +0200 Subject: [PATCH 09/47] Net RIC return --- plugins/Divera/Divera.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 9759e5e2..fc52aaa7 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -193,6 +193,7 @@ def run(typ, freq, data): else: logging.debug("RIC is net ident") + return else: loggin.debug("No Type is set", exc_info=True) From ab96a4db389997a943e82c47e8bb22052a3ac17a Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Fri, 1 May 2020 11:38:36 +0200 Subject: [PATCH 10/47] Change netric to top --- plugins/Divera/Divera.py | 60 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index fc52aaa7..90d33c67 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -91,23 +91,29 @@ def run(typ, freq, data): ric = globalVars.config.get("Divera","zvei_ric") 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 = '' + if isSignal(data["ric"]): + + # + # building message for POC + # + if data["function"] == '1': + priority = globalVars.config.get("Divera", "SubA") + elif data["function"] == '2': + priority = globalVars.config.get("Divera", "SubB") + elif data["function"] == '3': + priority = globalVars.config.get("Divera", "SubC") + elif data["function"] == '4': + priority = globalVars.config.get("Divera", "SubD") + else: + priority = '' - text = globalVars.config.get("Divera", "poc_text") - title = globalVars.config.get("Divera", "poc_title") - ric = globalVars.config.get("Divera", "poc_ric") + text = globalVars.config.get("Divera", "poc_text") + title = globalVars.config.get("Divera", "poc_title") + ric = globalVars.config.get("Divera", "poc_ric") + + else: + logging.debug("RIC is net ident") + return else: logging.warning("Invalid type: %s", typ) @@ -179,21 +185,17 @@ def run(typ, freq, data): })) elif typ == "POC": - if isSignal(data["ric"]): # start connection POC - conn = httplib.HTTPSConnection("www.divera247.com:443") - conn.request("GET", "/api/alarm", - urllib.urlencode({ - "accesskey": globalVars.config.get("Divera", "accesskey"), - "title": title, - "ric": ric, - "text": text, - "priority": priority, - })) + conn = httplib.HTTPSConnection("www.divera247.com:443") + conn.request("GET", "/api/alarm", + urllib.urlencode({ + "accesskey": globalVars.config.get("Divera", "accesskey"), + "title": title, + "ric": ric, + "text": text, + "priority": priority, + })) - else: - logging.debug("RIC is net ident") - return else: loggin.debug("No Type is set", exc_info=True) From 5136c6fb31dbc9b2b916de9466afb062b054b56c Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 13:03:18 +0200 Subject: [PATCH 11/47] Change if-else after net RIC (wrong definition) --- plugins/Divera/Divera.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 90d33c67..080e460a 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -93,6 +93,9 @@ def run(typ, freq, data): elif typ == "POC": if isSignal(data["ric"]): + logging.debug("RIC is net ident") + return + else: # # building message for POC # @@ -110,10 +113,7 @@ def run(typ, freq, data): text = globalVars.config.get("Divera", "poc_text") title = globalVars.config.get("Divera", "poc_title") ric = globalVars.config.get("Divera", "poc_ric") - - else: - logging.debug("RIC is net ident") - return + else: logging.warning("Invalid type: %s", typ) From c2b3c70a9c661c737cc3975ba669508519a0645f Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 14:02:58 +0200 Subject: [PATCH 12/47] Change description ZVEI --- plugins/Divera/Divera.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 080e460a..a8b0bb48 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -173,7 +173,7 @@ def run(typ, freq, data): })) elif typ == "ZVEI": - # start connection POC + # start connection ZVEI conn = httplib.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/alarm", urllib.urlencode({ From 75799dda80ee6f12bb2f75aafb769d2abf71a9bc Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 14:12:04 +0200 Subject: [PATCH 13/47] Change BOSWatch download to point 3 --- install.sh | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index 5470b243..3db9fd42 100644 --- a/install.sh +++ b/install.sh @@ -47,6 +47,7 @@ boswatchpath=/opt/boswatch reboot=false didBackup=false +# Checking for Backup # check for old version (for the old ones...) if [ -f $boswatchpath/BOSWatch/boswatch.py ]; then echo "Old installation found!" @@ -67,6 +68,7 @@ if [ -f $boswatchpath/boswatch.py ]; then didBackup=true fi +# Check for Flags in command line for (( i=1; i<=$#; i=$i+2 )); do t=$((i + 1)) eval arg=\$$i @@ -106,7 +108,22 @@ apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default li exitcodefunction $? download stuff tput cup 13 15 -echo "[ 3/10] [###-------]" +echo "[ 3/10] [#########-]" +tput cup 15 5 +echo "-> download BOSWatch..................." +cd $boswatchpath/ + +case $branch in + "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch-develop ;; + "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch-beta ;; + *) git clone -b master https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch ;; +esac + +tput cup 13 15 +echo "[ 4/10] [###-------]" tput cup 15 5 echo "-> download rtl_fm......................" cd $boswatchpath/install @@ -115,7 +132,7 @@ exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ tput cup 13 15 -echo "[ 4/10] [####------]" +echo "[ 5/10] [####------]" tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build @@ -134,7 +151,7 @@ exitcodefunction $? ldconfig rtl-sdr tput cup 13 15 -echo "[ 5/10] [#####-----]" +echo "[ 6/10] [#####-----]" tput cup 15 5 echo "-> download multimon-ng................" cd $boswatchpath/install @@ -145,7 +162,7 @@ exitcodefunction $? git-clone multimonNG cd $boswatchpath/install/multimonNG/ tput cup 13 15 -echo "[ 6/10] [######----]" +echo "[ 7/10] [######----]" tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build @@ -162,7 +179,7 @@ exitcodefunction $? qmakeinstall multimonNG tput cup 13 15 -echo "[ 7/10] [#######---]" +echo "[ 8/10] [#######---]" tput cup 15 5 echo "-> download MySQL connector for Python." cd $boswatchpath/install @@ -175,7 +192,7 @@ exitcodefunction $? untar mysql-connector cd $boswatchpath/install/mysql-connector-python* tput cup 13 15 -echo "[ 8/10] [########--]" +echo "[ 9/10] [########--]" tput cup 15 5 echo "-> install MySQL connector for Python.." chmod +x ./setup.py @@ -183,21 +200,6 @@ chmod +x ./setup.py exitcodefunction $? setup mysql-connector -tput cup 13 15 -echo "[ 9/10] [#########-]" -tput cup 15 5 -echo "-> download BOSWatch..................." -cd $boswatchpath/ - -case $branch in - "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ - exitcodefunction $? git-clone BOSWatch-develop ;; - "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ - exitcodefunction $? git-clone BOSWatch-beta ;; - *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ - exitcodefunction $? git-clone BOSWatch ;; -esac - tput cup 13 15 echo "[10/10] [##########]" tput cup 15 5 From 82d282a87cf5f5816568f619e948b2b7d52d950e Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 14:25:44 +0200 Subject: [PATCH 14/47] remove mysql-connector-download and install it via pip --- install.sh | 59 +++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/install.sh b/install.sh index 3db9fd42..bff2ed2b 100644 --- a/install.sh +++ b/install.sh @@ -89,26 +89,30 @@ for (( i=1; i<=$#; i=$i+2 )); do esac done +# Create default paths mkdir -p $boswatchpath mkdir -p $boswatchpath/install echo "" +# Update of computer tput cup 13 15 -echo "[ 1/10] [#---------]" +echo "[ 1/9] [#---------]" tput cup 15 5 echo "-> make an apt-get update................" apt-get update -y > $boswatchpath/install/setup_log.txt 2>&1 +# download software tput cup 13 15 -echo "[ 2/10] [##--------]" +echo "[ 2/9] [##--------]" tput cup 15 5 echo "-> download GIT and other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox >> $boswatchpath/install/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox python-pip >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? download stuff +# download BOSWatch via git tput cup 13 15 -echo "[ 3/10] [#########-]" +echo "[ 3/9] [#########-]" tput cup 15 5 echo "-> download BOSWatch..................." cd $boswatchpath/ @@ -122,8 +126,9 @@ case $branch in exitcodefunction $? git-clone BOSWatch ;; esac +# Download RTL-SDR tput cup 13 15 -echo "[ 4/10] [###-------]" +echo "[ 4/9] [###-------]" tput cup 15 5 echo "-> download rtl_fm......................" cd $boswatchpath/install @@ -131,8 +136,9 @@ git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatchpath/install/set exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ +# Compie RTL-FM tput cup 13 15 -echo "[ 5/10] [####------]" +echo "[ 5/9] [####------]" tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build @@ -149,20 +155,20 @@ ldconfig >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? ldconfig rtl-sdr - +# Download Multimon-NG tput cup 13 15 -echo "[ 6/10] [#####-----]" +echo "[ 6/9] [#####-----]" tput cup 15 5 echo "-> download multimon-ng................" cd $boswatchpath/install git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? git-clone multimonNG - cd $boswatchpath/install/multimonNG/ +# Compile Multimon-NG tput cup 13 15 -echo "[ 7/10] [######----]" +echo "[ 7/9] [######----]" tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build @@ -173,41 +179,28 @@ exitcodefunction $? qmake multimonNG make >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? make multimonNG - make install >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? qmakeinstall multimonNG - +# Download & Install MySQL-Connector for Python via pip tput cup 13 15 -echo "[ 8/10] [#######---]" +echo "[ 8/9] [#######---]" tput cup 15 5 -echo "-> download MySQL connector for Python." +echo "-> Download & Install MySQL connector for Python." cd $boswatchpath/install -wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 +pip install mysql-connector-python >> $boswatchpath/install/setup_log.txt 2>&1 exitcodefunction $? download mysql-connector -tar xfv mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 -exitcodefunction $? untar mysql-connector - -cd $boswatchpath/install/mysql-connector-python* - +# Blacklist DVB-Drivers tput cup 13 15 -echo "[ 9/10] [########--]" -tput cup 15 5 -echo "-> install MySQL connector for Python.." -chmod +x ./setup.py -./setup.py install >> $boswatchpath/install/setup_log.txt 2>&1 -exitcodefunction $? setup mysql-connector - - -tput cup 13 15 -echo "[10/10] [##########]" +echo "[9/9] [##########]" tput cup 15 5 echo "-> configure..........................." cd $boswatchpath/ chmod +x * echo $'# BOSWatch - blacklist the DVB drivers to avoid conflicts with the SDR driver\n blacklist dvb_usb_rtl28xxu \n blacklist rtl2830\n blacklist dvb_usb_v2\n blacklist dvb_core' >> /etc/modprobe.d/boswatch_blacklist_sdr.conf +# Installation is ready tput cup 17 1 echo "BOSWatch is now installed in $boswatchpath/" echo "Installation ready!" @@ -216,16 +209,14 @@ echo "Watch out: to run BOSWatch you have to modify the config.ini!" echo "Do the following step to do so:" echo "sudo nano $boswatchpath/config/config.ini" echo "and modify the config as you need. This step is optional if you are upgrading an old version of BOSWatch. " +echo "If not needed, please remove $boswatchpath/install" tput cnorm # cleanup mkdir $boswatchpath/log/install -p mv $boswatchpath/install/setup_log.txt $boswatchpath/log/install/ -rm $boswatchpath/install/ -R - -mv $boswatchpath/BOSWatch/* $boswatchpath/ -rm $boswatchpath/BOSWatch -R +#rm $boswatchpath/install/ -R #copy the template config to run boswatch cp $boswatchpath/config/config.template.ini $boswatchpath/config/config.ini From 858ee854f2cc8fe48f0bed29ea0b184825d83cf3 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 16:51:11 +0200 Subject: [PATCH 15/47] Add boswatch_install_path as temporary directory --- install.sh | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index bff2ed2b..c270cc0b 100644 --- a/install.sh +++ b/install.sh @@ -44,6 +44,7 @@ echo "Caution, script does not install a webserver with PHP and MySQL" echo "So you have to make up manually if you want to use MySQL support" boswatchpath=/opt/boswatch +boswatch_install_path=/opt/boswatch_install reboot=false didBackup=false @@ -97,83 +98,83 @@ echo "" # Update of computer tput cup 13 15 -echo "[ 1/9] [#---------]" +echo "[ 1/9] [#--------]" tput cup 15 5 echo "-> make an apt-get update................" -apt-get update -y > $boswatchpath/install/setup_log.txt 2>&1 +apt-get update -y > $boswatch_install_path/setup_log.txt 2>&1 # download software tput cup 13 15 -echo "[ 2/9] [##--------]" +echo "[ 2/9] [##-------]" tput cup 15 5 echo "-> download GIT and other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox python-pip >> $boswatchpath/install/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox python-pip >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? download stuff # download BOSWatch via git tput cup 13 15 -echo "[ 3/9] [#########-]" +echo "[ 3/9] [###------]" tput cup 15 5 echo "-> download BOSWatch..................." cd $boswatchpath/ case $branch in - "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch-develop ;; - "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch-beta ;; - *) git clone -b master https://github.com/Schrolli91/BOSWatch . >> $boswatchpath/install/setup_log.txt 2>&1 && \ + *) git clone -b master https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch ;; esac # Download RTL-SDR tput cup 13 15 -echo "[ 4/9] [###-------]" +echo "[ 4/9] [####-----]" tput cup 15 5 echo "-> download rtl_fm......................" cd $boswatchpath/install -git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatchpath/install/setup_log.txt 2>&1 +git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ # Compie RTL-FM tput cup 13 15 -echo "[ 5/9] [####------]" +echo "[ 5/9] [#####----]" tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build -cmake ../ -DINSTALL_UDEV_RULES=ON >> $boswatchpath/install/setup_log.txt 2>&1 +cmake ../ -DINSTALL_UDEV_RULES=ON >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? cmake rtl-sdr -make >> $boswatchpath/install/setup_log.txt 2>&1 +make >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? make rtl-sdr -make install >> $boswatchpath/install/setup_log.txt 2>&1 +make install >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? make-install rtl-sdr -ldconfig >> $boswatchpath/install/setup_log.txt 2>&1 +ldconfig >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? ldconfig rtl-sdr # Download Multimon-NG tput cup 13 15 -echo "[ 6/9] [#####-----]" +echo "[ 6/9] [######---]" tput cup 15 5 echo "-> download multimon-ng................" cd $boswatchpath/install -git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatchpath/install/setup_log.txt 2>&1 +git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? git-clone multimonNG cd $boswatchpath/install/multimonNG/ # Compile Multimon-NG tput cup 13 15 -echo "[ 7/9] [######----]" +echo "[ 7/9] [#######--]" tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build cd build -qmake ../multimon-ng.pro >> $boswatchpath/install/setup_log.txt 2>&1 +qmake ../multimon-ng.pro >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? qmake multimonNG make >> $boswatchpath/install/setup_log.txt 2>&1 @@ -184,16 +185,16 @@ exitcodefunction $? qmakeinstall multimonNG # Download & Install MySQL-Connector for Python via pip tput cup 13 15 -echo "[ 8/9] [#######---]" +echo "[ 8/9] [########-]" tput cup 15 5 echo "-> Download & Install MySQL connector for Python." cd $boswatchpath/install -pip install mysql-connector-python >> $boswatchpath/install/setup_log.txt 2>&1 +pip install mysql-connector-python >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? download mysql-connector # Blacklist DVB-Drivers tput cup 13 15 -echo "[9/9] [##########]" +echo "[9/9] [#########]" tput cup 15 5 echo "-> configure..........................." cd $boswatchpath/ @@ -215,8 +216,8 @@ tput cnorm # cleanup mkdir $boswatchpath/log/install -p -mv $boswatchpath/install/setup_log.txt $boswatchpath/log/install/ -#rm $boswatchpath/install/ -R +mv $boswatch_install_path/setup_log.txt $boswatchpath/log/install/ +rm $boswatch_install_path/ -R #copy the template config to run boswatch cp $boswatchpath/config/config.template.ini $boswatchpath/config/config.ini From a53d5609cc906a7f12ac3d2b2b8c297c0be89b77 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 16:53:17 +0200 Subject: [PATCH 16/47] Create new directory --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c270cc0b..c8748b20 100644 --- a/install.sh +++ b/install.sh @@ -92,7 +92,7 @@ done # Create default paths mkdir -p $boswatchpath -mkdir -p $boswatchpath/install +mkdir -p $boswatch_install_path echo "" From b2d49244f86096f6c1395e5eb41ff50e0f49198b Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 17:08:59 +0200 Subject: [PATCH 17/47] Change path-Variable --- install.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index c8748b20..0739a2ae 100644 --- a/install.sh +++ b/install.sh @@ -6,17 +6,17 @@ function exitcodefunction { module=$3 if [ $errorcode -ne "0" ]; then - echo "Action: $action on $module failed." >> $boswatchpath/install/setup_log.txt - echo "Exitcode: $errorcode" >> $boswatchpath/install/setup_log.txt + echo "Action: $action on $module failed." >> $boswatch_install_path/setup_log.txt + echo "Exitcode: $errorcode" >> $boswatch_install_path/setup_log.txt echo "" echo "Action: $action on $module failed." echo "Exitcode: $errorcode" echo "" echo " -> If you want to open an issue at https://github.com/Schrolli91/BOSWatch/issues" - echo " please post the logfile, located at $boswatchpath/install/setup_log.txt" + echo " please post the logfile, located at $boswatch_install_path/setup_log.txt" exit 1 else - echo "Action: $action on $module ok." >> $boswatchpath/install/setup_log.txt + echo "Action: $action on $module ok." >> $boswatch_install_path/setup_log.txt fi } @@ -132,7 +132,7 @@ tput cup 13 15 echo "[ 4/9] [####-----]" tput cup 15 5 echo "-> download rtl_fm......................" -cd $boswatchpath/install +cd $boswatch_install_path git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ @@ -161,11 +161,11 @@ tput cup 13 15 echo "[ 6/9] [######---]" tput cup 15 5 echo "-> download multimon-ng................" -cd $boswatchpath/install +cd $boswatch_install_path git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? git-clone multimonNG -cd $boswatchpath/install/multimonNG/ +cd $boswatch_install_path/multimonNG/ # Compile Multimon-NG tput cup 13 15 @@ -177,10 +177,10 @@ cd build qmake ../multimon-ng.pro >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? qmake multimonNG -make >> $boswatchpath/install/setup_log.txt 2>&1 +make >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? make multimonNG -make install >> $boswatchpath/install/setup_log.txt 2>&1 +make install >> $boswatch_install_path/setup_log.txt 2>&1 exitcodefunction $? qmakeinstall multimonNG # Download & Install MySQL-Connector for Python via pip @@ -188,9 +188,9 @@ tput cup 13 15 echo "[ 8/9] [########-]" tput cup 15 5 echo "-> Download & Install MySQL connector for Python." -cd $boswatchpath/install +cd $boswatch_install_path pip install mysql-connector-python >> $boswatch_install_path/setup_log.txt 2>&1 -exitcodefunction $? download mysql-connector +exitcodefunction $? install mysql-connector # Blacklist DVB-Drivers tput cup 13 15 @@ -210,7 +210,6 @@ echo "Watch out: to run BOSWatch you have to modify the config.ini!" echo "Do the following step to do so:" echo "sudo nano $boswatchpath/config/config.ini" echo "and modify the config as you need. This step is optional if you are upgrading an old version of BOSWatch. " -echo "If not needed, please remove $boswatchpath/install" tput cnorm From 8ea90d5e5316c0026adfb44401a9e880965baa20 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sat, 2 May 2020 17:31:06 +0200 Subject: [PATCH 18/47] Change permissions and remove chmod in install.sh --- install.sh | 1 - 1 file changed, 1 deletion(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 0739a2ae..f13867eb --- a/install.sh +++ b/install.sh @@ -198,7 +198,6 @@ echo "[9/9] [#########]" tput cup 15 5 echo "-> configure..........................." cd $boswatchpath/ -chmod +x * echo $'# BOSWatch - blacklist the DVB drivers to avoid conflicts with the SDR driver\n blacklist dvb_usb_rtl28xxu \n blacklist rtl2830\n blacklist dvb_usb_v2\n blacklist dvb_core' >> /etc/modprobe.d/boswatch_blacklist_sdr.conf # Installation is ready From 743f3d079ce790cb50d0d28fea2ec32e90a44919 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Mon, 4 May 2020 17:28:58 +0200 Subject: [PATCH 19/47] remove beta --- install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install.sh b/install.sh index f13867eb..0335aee2 100755 --- a/install.sh +++ b/install.sh @@ -121,8 +121,6 @@ cd $boswatchpath/ case $branch in "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch-develop ;; - "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ - exitcodefunction $? git-clone BOSWatch-beta ;; *) git clone -b master https://github.com/Schrolli91/BOSWatch . >> $boswatch_install_path/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch ;; esac From b46dc26a50e2464aa5a8ec6e614b5c272e09c8b2 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Mon, 4 May 2020 18:23:22 +0200 Subject: [PATCH 20/47] Add more Descriptions --- plugins/Divera/Divera.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index a8b0bb48..10d6e340 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -128,6 +128,8 @@ def run(typ, freq, data): # replace the wildcards text = wildcardHandler.replaceWildcards(text, data) title = wildcardHandler.replaceWildcards(title, data) + + # replace the wildcards in FMS; RIC is used for ZVEI/POC if typ == "FMS": vehicle = wildcardHandler.replaceWildcards(vehicle, data) else: @@ -136,10 +138,14 @@ def run(typ, freq, data): # Logging data to send logging.debug("Title : %s", title) + + # ZVEI, POC is logged, if not FMS is used if typ == "FMS": logging.debug("Vehicle : %s", vehicle) else: logging.debug("RIC : %s", ric) + + # Logging normal logging.debug("Text : %s", text) logging.debug("Priority: %s", priority) From 13692eb261515d7d9aab00320ddbd4d6764176eb Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Tue, 5 May 2020 17:17:51 +0200 Subject: [PATCH 21/47] Update Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a44a75..ce7cfb74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,11 @@ ### __[v2.5.2]__ - unreleased ##### Added ##### Changed +- install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) ##### Deprecated ##### Removed ##### Fixed +- install.sh: old version of mysql-connector-python removed; add new via pip [#452](https://github.com/Schrolli91/BOSWatch/pull/452) [#445](https://github.com/Schrolli91/BOSWatch/issues/445) ##### Security From 5bbb1b01062aab5a5b0238bf4cb226b3cf6d1875 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Tue, 5 May 2020 17:55:59 +0200 Subject: [PATCH 22/47] if-clauses; change zvei_ric to zvei_id; combine wildcards with logging --- config/config.template.ini | 4 +-- plugins/Divera/Divera.py | 51 ++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 80ac8c5d..f7572aba 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -501,8 +501,8 @@ poc_ric = %DESCR% zvei_prio = true zvei_title = Alarm: %ZVEI% zvei_text = %DATE% %TIME%: %ZVEI% -# zvei_ric working at 6 characters or more -zvei_ric = %DESCR% +# zvei_id working at 6 characters or more; later name of alarm-RIC in divera +zvei_id = %DESCR% # Section for FMS fms_prio = true diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 10d6e340..5811f8f3 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -88,7 +88,7 @@ def run(typ, freq, data): text = globalVars.config.get("Divera", "zvei_text") title = globalVars.config.get("Divera", "zvei_title") priority = globalVars.config.get("Divera","zvei_prio") - ric = globalVars.config.get("Divera","zvei_ric") + zvei_id = globalVars.config.get("Divera","zvei_id") elif typ == "POC": if isSignal(data["ric"]): @@ -124,30 +124,24 @@ def run(typ, freq, data): # Divera-Request # logging.debug("send Divera for %s", typ) - - # replace the wildcards - text = wildcardHandler.replaceWildcards(text, data) - title = wildcardHandler.replaceWildcards(title, data) - - # replace the wildcards in FMS; RIC is used for ZVEI/POC - if typ == "FMS": - vehicle = wildcardHandler.replaceWildcards(vehicle, data) - else: - ric = wildcardHandler.replaceWildcards(ric, data) - - # Logging data to send + # Replace wildcards & Logging data to send + title = wildcardHandler.replaceWildcards(title, data) logging.debug("Title : %s", title) + text = wildcardHandler.replaceWildcards(text, data) + logging.debug("Text : %s", text) - # ZVEI, POC is logged, if not FMS is used if typ == "FMS": + vehicle = wildcardHandler.replaceWildcards(vehicle, data) logging.debug("Vehicle : %s", vehicle) - else: + elif typ == "POC": + ric = wildcardHandler.replaceWildcards(ric, data) logging.debug("RIC : %s", ric) - - # Logging normal - logging.debug("Text : %s", text) - logging.debug("Priority: %s", priority) + elif typ == "ZVEI": + zvei_id = wildcardHandler.replaceWildcards(zvei_id, data) + logging.debug("ZVEI_ID : %s", zvei_id) + else: + logging.info("No wildcards to replace and no Typ selected!") # check priority value if (priority != 'false') and (priority != 'true'): @@ -157,11 +151,20 @@ def run(typ, freq, data): # Check FMS if typ == "FMS": if (vehicle == ''): - logging.info("No Vehicle set!"); + logging.info("No Vehicle set!") - else: + # Check POC + elif typ == "POC": if (ric == ''): - logging.info("No RIC set!"); + logging.info("No RIC set!") + + # Check ZVEI + elif typ == "ZVEI": + if (zvei_id == ''): + logging.info("No ZVEI_ID set!") + + else: + logging.info("No ZVEI, FMS or POC alarm") # start connection to Divera if typ == "FMS": @@ -179,13 +182,13 @@ def run(typ, freq, data): })) elif typ == "ZVEI": - # start connection ZVEI + # start connection ZVEI; zvei_id in Divera is alarm-RIC! conn = httplib.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/alarm", urllib.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), "title": title, - "ric": ric, + "ric": zvei_id, "text": text, "priority": priority, })) From 52039a056eb5ba76f06546f4ae6f1422f8be7c0d Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Tue, 5 May 2020 18:03:40 +0200 Subject: [PATCH 23/47] add description in config.template.ini --- config/config.template.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index f7572aba..4c33f2ad 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -494,6 +494,7 @@ SubD = poc_title = %DESCR%: %MSG% poc_text = %DATE% %TIME% - %DESCR%: %MSG% +# poc_ric is alarm-RIC in divera poc_ric = %DESCR% # Section for ZVEI @@ -508,6 +509,7 @@ zvei_id = %DESCR% fms_prio = true fms_title = FMS: %FMS% fms_text = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR% +# fms_vehicle is alarm-RIC in divera fms_vehicle = %DESCR% From 784a38b3b3b7e50c47aa6a57c30198767c4607bd Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Tue, 5 May 2020 21:43:53 +0200 Subject: [PATCH 24/47] Update Changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a44a75..d98ade2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### __[v2.5.2]__ - unreleased ##### Added ##### Changed +- Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) ##### Deprecated ##### Removed ##### Fixed From 9fb4e5fbe95b4bad3ebdffd57b734a9332a0c10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Sat, 11 Jul 2020 13:31:57 +0200 Subject: [PATCH 25/47] New plugin fhemCmd to execute commands in FHEM home automation --- config/config.template.ini | 21 +++++++ plugins/fhemCmd/fhemCmd.py | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 plugins/fhemCmd/fhemCmd.py diff --git a/config/config.template.ini b/config/config.template.ini index 4c33f2ad..8d2a9a4b 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -182,6 +182,7 @@ yowsup = 0 hue = 0 Divera = 0 gpiocontrol = 0 +fhemCmd = 0 # for developing - template-module template = 0 @@ -525,6 +526,26 @@ triggertime = 180 #POC Rics that trigger PIN (empty: allow all, separator ",") activerics = 1234567,1234568 +[fhemCmd] +# choose one of "http", "https" or "telnet" +protocol = http + +# servername or IP address +server = 192.168.0.1 + +# numeric port +port = 8083 + +# username if required +username = dummyUser + +# password if required +password = dummyPassword + +# desired command to execute +commandFMS = set SteckdoseSchlafzimmerEinsatz on-for-timer 90 +commandZVEI = +commandPOC = ##################### ##### Not ready yet # diff --git a/plugins/fhemCmd/fhemCmd.py b/plugins/fhemCmd/fhemCmd.py new file mode 100644 index 00000000..567f4184 --- /dev/null +++ b/plugins/fhemCmd/fhemCmd.py @@ -0,0 +1,113 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" +Plugin for calling FHEM home automation + +@author: Marco Schotthöfer + +@requires: python-fhem (pip install fhem) +""" + +# +# Imports +# +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 +from includes.helper import wildcardHandler +import fhem + +## +# +# 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("fhemCmd"): #read and debug the config (let empty if no config used) + + protocol = globalVars.config.get("fhemCmd", "protocol") + logging.debug("protocol: %s", protocol) + + server = globalVars.config.get("fhemCmd", "server") + logging.debug("server: %s", server) + + port = globalVars.config.get("fhemCmd", "port") + logging.debug("port: %s", port) + + username = globalVars.config.get("fhemCmd", "username") + logging.debug("username: %s", username) + + password = globalVars.config.get("fhemCmd", "password") + logging.debug("password: %s", password) + + ########## User Plugin CODE ########## + fh = fhem.Fhem(server=server, protocol=protocol, port=port, username=username, password=password) + + if typ == "FMS": + fhemCommand = globalVars.config.get("fhemCmd", "commandFMS") + elif typ == "ZVEI": + fhemCommand = globalVars.config.get("fhemCmd", "commandZVEI") + elif typ == "POC": + fhemCommand = globalVars.config.get("fhemCmd", "commandPOC") + else: + logging.warning("Invalid Typ: %s", typ) + return False + + fhemCommand = wildcardHandler.replaceWildcards(fhemCommand, data) + logging.debug("fhemCommand: %s", fhemCommand) + + fh.send_cmd(fhemCommand) + del fh + ########## User Plugin CODE ########## + + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) From f18e47334e963f5b7a7e2737f96a868a909f9a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Sat, 11 Jul 2020 16:39:07 +0200 Subject: [PATCH 26/47] Instantiate FHEM object only in case of valid typ --- plugins/fhemCmd/fhemCmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/fhemCmd/fhemCmd.py b/plugins/fhemCmd/fhemCmd.py index 567f4184..2658e2e4 100644 --- a/plugins/fhemCmd/fhemCmd.py +++ b/plugins/fhemCmd/fhemCmd.py @@ -89,8 +89,6 @@ def run(typ,freq,data): logging.debug("password: %s", password) ########## User Plugin CODE ########## - fh = fhem.Fhem(server=server, protocol=protocol, port=port, username=username, password=password) - if typ == "FMS": fhemCommand = globalVars.config.get("fhemCmd", "commandFMS") elif typ == "ZVEI": @@ -104,6 +102,8 @@ def run(typ,freq,data): fhemCommand = wildcardHandler.replaceWildcards(fhemCommand, data) logging.debug("fhemCommand: %s", fhemCommand) + fh = fhem.Fhem(server=server, protocol=protocol, port=port, username=username, password=password) + fh.send_cmd(fhemCommand) del fh ########## User Plugin CODE ########## From 1548e2fdfcfedf7470257373afbe4a2c65c9e412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Sat, 11 Jul 2020 16:49:28 +0200 Subject: [PATCH 27/47] Add requirements file --- plugins/fhemCmd/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 plugins/fhemCmd/requirements.txt diff --git a/plugins/fhemCmd/requirements.txt b/plugins/fhemCmd/requirements.txt new file mode 100644 index 00000000..a852eb52 --- /dev/null +++ b/plugins/fhemCmd/requirements.txt @@ -0,0 +1 @@ +fhem From cdf37c417e3ed5e60bb047310b50ede930d0da29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Mon, 13 Jul 2020 10:29:12 +0200 Subject: [PATCH 28/47] Added changelog entry for new fhemCmd plugin --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f684a418..545b8536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### __[v2.5.2]__ - unreleased ##### Added +- fhemCmd-Plugin: Plugin zum Auslösen von Aktionen in FHEM Heimautomatisierung. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) From a4ed7089b81b2a329f90e9c1163aca451f0f521a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Mon, 13 Jul 2020 10:48:00 +0200 Subject: [PATCH 29/47] Changelog entry in english language --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 545b8536..96569e96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### __[v2.5.2]__ - unreleased ##### Added -- fhemCmd-Plugin: Plugin zum Auslösen von Aktionen in FHEM Heimautomatisierung. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) +- fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) From a1bda7ebf61f2ff519b97be2bb3b8c2fdb65025b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Fri, 17 Jul 2020 06:46:22 +0200 Subject: [PATCH 30/47] Add field "ricFuncChar" in data structure for POC messages as a combination of "ric" and "functionChar" for using in RegEx filter. --- includes/decoders/poc.py | 1 + plugins/README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index e5b9b6d3..bf906fdc 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -163,6 +163,7 @@ def decode(freq, decoded): 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") + data["ricFuncChar"] = data["ric"] + data["functionChar"] logging.info("POCSAG%s: %s %s %s ", data["bitrate"], data["ric"], data["function"], data["msg"]) diff --git a/plugins/README.md b/plugins/README.md index be512ad2..bafee9e1 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -203,6 +203,7 @@ In the data map are the folowing informations: - ric - function - functionChar +- ricFuncChar - msg - bitrate - description From ac767ce0204580f3039cbd7f47d3a8434659043f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Schotth=C3=B6fer?= Date: Fri, 17 Jul 2020 06:50:47 +0200 Subject: [PATCH 31/47] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96569e96..3c2fbe22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### __[v2.5.2]__ - unreleased ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) +- Add field "ricFuncChar" in data structure for POC messages as a combination of "ric" and "functionChar" for using in RegEx filter. [#459](https://github.com/Schrolli91/BOSWatch/pull/459) ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) From 28e9a9117379956ff24d87d73d3c1609fdc4eb46 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 28 Jul 2020 23:35:17 +0200 Subject: [PATCH 32/47] Update gpiocontrol.py Fixing indentation-error reported on #458 --- plugins/gpiocontrol/gpiocontrol.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index 7662fe8c..f7daf90f 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -92,9 +92,9 @@ def run(typ,freq,data): #logging.warning("%s not supported", typ) elif typ == "POC": if globalVars.config.get("gpiocontrol", "activerics") == "": - th = threading.Thread(target = trigger) - th.start() - else + th = threading.Thread(target = trigger) + th.start() + else: if data["ric"] in globalVars.config.get("gpiocontrol", "activerics"): th = threading.Thread(target = trigger) th.start() From d75800e8d3a0865172ea1252827de0684cc9004f Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 1 Aug 2020 12:43:35 +0200 Subject: [PATCH 33/47] Fixing another indentation error Fixing various errors and adding changelog --- CHANGELOG.md | 4 ++++ plugins/gpiocontrol/gpiocontrol.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b72530e6..16fbc115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### __[v2.5.2]__ - 01.08.2020 +##### Fixed +- GPIOcontrol plugin: Fixing indentation errors. [#465](https://github.com/Schrolli91/BOSWatch/pull/465) + ### __[v2.5.1]__ - 28.04.2020 ##### Added - Plugin requirements: Added requirements.txt for all plugins requiring extra python packages so the install will be easier [#446](https://github.com/Schrolli91/BOSWatch/pull/446) diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index f7daf90f..63334d1a 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -92,14 +92,14 @@ def run(typ,freq,data): #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") + 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 e582c4a03033bc13de81307e8b84f9afa25d0418 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 3 Aug 2020 14:27:17 +0200 Subject: [PATCH 34/47] Update globalVars.py --- includes/globalVars.py | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/globalVars.py b/includes/globalVars.py index 526ead2a..b0b50fb7 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -13,7 +13,6 @@ branch = "dev" buildDate = "unreleased" - # Global variables config = 0 script_path = "" From 3fd9e92bcdec47e2cc723107a1b869a9e79c4145 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 3 Aug 2020 14:27:30 +0200 Subject: [PATCH 35/47] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2e6e05..53dbf32a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ # Changelog - ### __[v2.5.2]__ - unreleased ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) From 4958ae4c1d97ee1fcf9d45df3b98f975402cdc63 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Mon, 28 Sep 2020 20:54:34 +0200 Subject: [PATCH 36/47] Update Telegram.py Set message parse mode to HTML to allow a number of formatting options like bold and italic. See https://core.telegram.org/bots/api#formatting-options for full details. --- plugins/Telegram/Telegram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 2120d75c..837aea00 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -94,7 +94,7 @@ def run(typ,freq,data): bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, text) + bot.sendMessage('%s' % BOTChatIDAPIKey, text, parse_mode=telegram.ParseMode.HTML) # Generate location information only for specific RIC if typ == "POC" and data["ric"] == RICforLocationAPIKey: From 7e4ba5188fe7ef4bc4151385511e5112b18a2c1a Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Mon, 28 Sep 2020 21:00:22 +0200 Subject: [PATCH 37/47] Update config.template.ini Allow simple HTML stype formatting options like for bold and for italic in the Telegram plugin. See https://core.telegram.org/bots/api#formatting-options for full details. --- config/config.template.ini | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 8d2a9a4b..c677cb2b 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -426,14 +426,17 @@ GoogleAPIKey = # Use the following format: CityOfOrigin+Street+Number RoutingOrigin = MyCity+MyStreet+MyNumber -#Wildcards can be used, see end of the file! +# Wildcards can be used, see end of the file! +# In addition, feel free to use simple HTML stlye tags like %FMS% FMS_message = %DATE% %TIME%: %FMS% -#Wildcards can be used, see end of the file! +#W ildcards can be used, see end of the file! +# In addition, feel free to use simple HTML stlye tags like %ZVEI% ZVEI_message = %DATE% %TIME%: %ZVEI% -#Wildcards can be used, see end of the file! -POC_message = %MSG% +# Wildcards can be used, see end of the file! +# In addition, feel free to use simple HTML stlye tags like %DESCR% +POC_message = %DESCR%%BR%%MSG% [yowsup] From 8ee395ce2667eb3781e49cc5f1e84b962a1bb939 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Mon, 28 Sep 2020 21:09:55 +0200 Subject: [PATCH 38/47] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53dbf32a..48486a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) +- Telegram Plugin: Add support for simple HTML style message formatting. [#482](https://github.com/Schrolli91/BOSWatch/pull/482) ##### Deprecated ##### Removed ##### Fixed From b14fc23c8c012c9e92ed09adb650e3b8a36b4840 Mon Sep 17 00:00:00 2001 From: MrDuckSpace Date: Fri, 18 Dec 2020 15:15:38 +0100 Subject: [PATCH 39/47] Added Plugin MQTT --- config/config.template.ini | 10 ++++ plugins/mqtt/mqtt.py | 108 ++++++++++++++++++++++++++++++++++ plugins/mqtt/requirements.txt | 1 + 3 files changed, 119 insertions(+) create mode 100644 plugins/mqtt/mqtt.py create mode 100644 plugins/mqtt/requirements.txt diff --git a/config/config.template.ini b/config/config.template.ini index af5da011..21d50a9d 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -182,6 +182,7 @@ yowsup = 0 hue = 0 Divera = 0 gpiocontrol = 0 +mqtt = 0 # for developing - template-module template = 0 @@ -519,6 +520,15 @@ triggertime = 180 #POC Rics that trigger PIN (empty: allow all, separator ",") activerics = 1234567,1234568 +[mqtt] +#Plugin for publish POCSAG Alarm wit MQTT + +#Adress from MQTT-Broker (Example: 192.168.178.27) +brokeraddress = + +#Example: +#topic = alarm/posac +topic = ##################### ##### Not ready yet # diff --git a/plugins/mqtt/mqtt.py b/plugins/mqtt/mqtt.py new file mode 100644 index 00000000..ed121b66 --- /dev/null +++ b/plugins/mqtt/mqtt.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" +@author: KS + +@requires: paho-mqtt +""" + +# +# Imports +# +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 + +import paho.mqtt.client as mqtt +import json + +## +# +# 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("mqtt"): #read and debug the config (let empty if no config used) + + logging.debug(globalVars.config.get("mqtt", "brokeraddress")) + logging.debug(globalVars.config.get("mqtt", "topic")) + ########## User Plugin CODE ########## + broker_address = globalVars.config.get("mqtt", "brokeraddress") + topic = globalVars.config.get("mqtt", "topic") + mqttClient = mqtt.Client() + + if typ == "FMS": + logging.warning("%s not supported", typ) + elif typ == "ZVEI": + logging.warning("%s not supported", typ) + elif typ == "POC": + functionText = "%FUNCTEXT%" + functionText = wildcardHandler.replaceWildcards(functionText, data) + x = { + "ric": data["ric"], + "function": data["function"], + "functionText": functionText, + "functionChar": data["functionChar"], + "msg": data["msg"], + "bitrate": data["bitrate"], + "description": data["description"], + "timestamp": timeHandler.curtime() + } + y = json.dumps(x) + mqttClient.connect(broker_address) + mqttClient.publish(topic,y) + else: + logging.warning("Invalid Typ: %s", typ) + ########## User Plugin CODE ########## + + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) diff --git a/plugins/mqtt/requirements.txt b/plugins/mqtt/requirements.txt new file mode 100644 index 00000000..8579e8b2 --- /dev/null +++ b/plugins/mqtt/requirements.txt @@ -0,0 +1 @@ +paho-mqtt From d833bc5389555e9a34e235becc93f7a16b1ffff1 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 18 Dec 2020 15:19:45 +0100 Subject: [PATCH 40/47] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b72530e6..2e432486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +##### Added +- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [498]( +https://github.com/Schrolli91/BOSWatch/pull/498) +##### Fixed ### __[v2.5.1]__ - 28.04.2020 ##### Added From b8c9edefe5d4dfc97805b7f985b2b422c6c593a8 Mon Sep 17 00:00:00 2001 From: mrduckspace <34840030+mrduckspace@users.noreply.github.com> Date: Fri, 18 Dec 2020 15:20:15 +0100 Subject: [PATCH 41/47] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e432486..7a3efeaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog ##### Added -- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [498]( +- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [#498]( https://github.com/Schrolli91/BOSWatch/pull/498) ##### Fixed From 9101ce33e17d5fef852e135f9ea80d760372b9d8 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 18 Dec 2020 19:19:51 +0100 Subject: [PATCH 42/47] Update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4340dda8..73692f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,11 @@ # Changelog -##### Added -- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [#498]( -https://github.com/Schrolli91/BOSWatch/pull/498) -##### Fixed ### __[v2.5.2]__ - unreleased ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) - Add field "ricFuncChar" in data structure for POC messages as a combination of "ric" and "functionChar" for using in RegEx filter. [#459](https://github.com/Schrolli91/BOSWatch/pull/459) +- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [#498]( +https://github.com/Schrolli91/BOSWatch/pull/498) ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) From 7fe98e25166c165bc742600938e6c5913b0a919a Mon Sep 17 00:00:00 2001 From: mrduckspace Date: Tue, 22 Dec 2020 13:33:23 +0100 Subject: [PATCH 43/47] FMS and ZVEI Support --- config/config.template.ini | 11 +++-------- plugins/mqtt/mqtt.py | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index f6d740a2..01aca9d3 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -552,14 +552,9 @@ commandZVEI = commandPOC = [mqtt] -#Plugin for publish POCSAG Alarm wit MQTT - -#Adress from MQTT-Broker (Example: 192.168.178.27) -brokeraddress = - -#Example: -#topic = alarm/posac -topic = +#Adress from MQTT-Broker +brokeraddress = 192.168.178.27 +topic = alarm/posac ##################### ##### Not ready yet # diff --git a/plugins/mqtt/mqtt.py b/plugins/mqtt/mqtt.py index ed121b66..683d7d67 100644 --- a/plugins/mqtt/mqtt.py +++ b/plugins/mqtt/mqtt.py @@ -80,9 +80,21 @@ def run(typ,freq,data): mqttClient = mqtt.Client() if typ == "FMS": - logging.warning("%s not supported", typ) + x = { + "fms": data["fms"], + "status": data["status"], + "direction": data["direction"], + "directionText": data["directionText"], + "tsi": data["tsi"], + "description": data["description"], + "timestamp": timeHandler.curtime() + } elif typ == "ZVEI": - logging.warning("%s not supported", typ) + x = { + "zvei": data["zvei"], + "description": data["description"], + "timestamp": timeHandler.curtime() + } elif typ == "POC": functionText = "%FUNCTEXT%" functionText = wildcardHandler.replaceWildcards(functionText, data) @@ -96,11 +108,12 @@ def run(typ,freq,data): "description": data["description"], "timestamp": timeHandler.curtime() } - y = json.dumps(x) - mqttClient.connect(broker_address) - mqttClient.publish(topic,y) else: logging.warning("Invalid Typ: %s", typ) + + y = json.dumps(x) + mqttClient.connect(broker_address) + mqttClient.publish(topic,y) ########## User Plugin CODE ########## except: From 68cb7c6b1732d5d8802ad881baf825722790ed15 Mon Sep 17 00:00:00 2001 From: mrduckspace Date: Tue, 22 Dec 2020 22:09:58 +0100 Subject: [PATCH 44/47] Update config.template.ini --- 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 01aca9d3..e20a7eb4 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -554,7 +554,7 @@ commandPOC = [mqtt] #Adress from MQTT-Broker brokeraddress = 192.168.178.27 -topic = alarm/posac +topic = alarm/data ##################### ##### Not ready yet # From e7a62ba1a369cd11e13aa137cdadfa259e40bbd8 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 7 Jan 2021 12:09:02 +0100 Subject: [PATCH 45/47] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73692f88..70f1fd43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) - Add field "ricFuncChar" in data structure for POC messages as a combination of "ric" and "functionChar" for using in RegEx filter. [#459](https://github.com/Schrolli91/BOSWatch/pull/459) -- MQTT: Plugin für Übermittlung von POSAC an einen MQTT-Broker [#498]( -https://github.com/Schrolli91/BOSWatch/pull/498) +- MQTT Plugin: Send alarms to an MQTT broker [#498](https://github.com/Schrolli91/BOSWatch/pull/498) ##### Changed - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) From 4f5b4854c71f3ad0f0b4114db9b87256fb6b9644 Mon Sep 17 00:00:00 2001 From: Schrolli91 Date: Fri, 8 Jan 2021 19:02:02 +0100 Subject: [PATCH 46/47] prepare for next version --- CHANGELOG.md | 17 ++++++++++++----- includes/globalVars.py | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f1fd43..31070021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog -### __[v2.5.2]__ - unreleased + +### __[v2.5.3]__ - unreleased +##### Added +##### Changed +##### Deprecated +##### Removed +##### Fixed +##### Security + + +### __[v2.5.2]__ - 08.01.2021 ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) - Add field "ricFuncChar" in data structure for POC messages as a combination of "ric" and "functionChar" for using in RegEx filter. [#459](https://github.com/Schrolli91/BOSWatch/pull/459) @@ -9,12 +19,9 @@ - Divera Plugin: Add individual alarms for FMS, ZVEI and POC. [#451](https://github.com/Schrolli91/BOSWatch/pull/451) - install.sh: local git repo available at /opt/boswatch (or at your own path). Updates easier with `git pull` in /opt/boswatch. [#452](https://github.com/Schrolli91/BOSWatch/pull/452) - Telegram Plugin: Add support for simple HTML style message formatting. [#482](https://github.com/Schrolli91/BOSWatch/pull/482) -##### Deprecated -##### Removed ##### Fixed - install.sh: old version of mysql-connector-python removed; add new via pip [#452](https://github.com/Schrolli91/BOSWatch/pull/452) [#445](https://github.com/Schrolli91/BOSWatch/issues/445) - GPIOcontrol plugin: Fixing indentation errors. [#465](https://github.com/Schrolli91/BOSWatch/pull/465) -##### Security ### __[v2.5.1]__ - 28.04.2020 @@ -128,7 +135,7 @@ Zum schreiben des Changelog's siehe: http://keepachangelog.com/de/1.0.0/ -### __[v#.#]__ - date +### __[v#.#]__ - unreleased ##### Added ##### Changed ##### Deprecated diff --git a/includes/globalVars.py b/includes/globalVars.py index b0b50fb7..14c7ea9a 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,7 +9,7 @@ """ # version info -versionNr = "2.5.2" +versionNr = "2.5.3" branch = "dev" buildDate = "unreleased" From e2e7f01692e84f7537cec33558469fd69420f808 Mon Sep 17 00:00:00 2001 From: Schrolli91 Date: Fri, 8 Jan 2021 19:05:14 +0100 Subject: [PATCH 47/47] relase --- CHANGELOG.md | 9 --------- includes/globalVars.py | 6 +++--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31070021..eea44a7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,6 @@ # Changelog -### __[v2.5.3]__ - unreleased -##### Added -##### Changed -##### Deprecated -##### Removed -##### Fixed -##### Security - - ### __[v2.5.2]__ - 08.01.2021 ##### Added - fhemCmd-Plugin: New plugin fhemCmd to execute commands in FHEM home automation. [#457](https://github.com/Schrolli91/BOSWatch/pull/457) diff --git a/includes/globalVars.py b/includes/globalVars.py index 14c7ea9a..82f48580 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,9 +9,9 @@ """ # version info -versionNr = "2.5.3" -branch = "dev" -buildDate = "unreleased" +versionNr = "2.5.2" +branch = "master" +buildDate = "08.01.2021" # Global variables config = 0