From 4958ae4c1d97ee1fcf9d45df3b98f975402cdc63 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Mon, 28 Sep 2020 20:54:34 +0200 Subject: [PATCH 01/11] 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 2120d75..837aea0 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 02/11] 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 8d2a9a4..c677cb2 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 03/11] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53dbf32..48486a4 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 04/11] 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 af5da01..21d50a9 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 0000000..ed121b6 --- /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 0000000..8579e8b --- /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 05/11] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b72530e..2e43248 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 06/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e43248..7a3efea 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 07/11] Update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4340dda..73692f8 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 08/11] 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 f6d740a..01aca9d 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 ed121b6..683d7d6 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 09/11] 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 01aca9d..e20a7eb 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 10/11] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73692f8..70f1fd4 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 11/11] 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 70f1fd4..3107002 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 b0b50fb..14c7ea9 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,7 +9,7 @@ Global variables """ # version info -versionNr = "2.5.2" +versionNr = "2.5.3" branch = "dev" buildDate = "unreleased"