diff --git a/asterisk/__init__.py b/asterisk/__init__.py index d67cc5e18..b415b3427 100755 --- a/asterisk/__init__.py +++ b/asterisk/__init__.py @@ -31,7 +31,7 @@ class Asterisk(SmartPlugin): - PLUGIN_VERSION = "1.4.1" + PLUGIN_VERSION = "1.4.2" DB = 'ast_db' DEV = 'ast_dev' @@ -237,8 +237,27 @@ def hangup(self, hang): self._command({'Action': 'Hangup', 'Channel': channel}, reply=False) def found_terminator(self, client, data): - """called upon data reception""" - data = data.decode() + """called then terminator is found + + :param client: tcp client which is used for the connection + :param str data: the response from asterisk server + :return : None + """ + if isinstance(data, bytes): + data = data.decode() + + """ + the response will be normally like ``key: value`` + exception is start of communication which presents e.g. + ``` + Asterisk Call Manager/5.0.4 + Response: Success + Message: Authentication accepted + ``` + The following code puts everything into the dict ``event`` + It only implements a very basic inspection of the response + """ + self.logger.debug(f"data to inspect: {data}") event = {} for line in data.splitlines(): key, sep, value = line.partition(': ') diff --git a/asterisk/plugin.yaml b/asterisk/plugin.yaml index 02c37d02b..7a8772e9f 100755 --- a/asterisk/plugin.yaml +++ b/asterisk/plugin.yaml @@ -5,13 +5,13 @@ plugin: description: de: 'Ansteuerung einer Asterisk Telefonanlage' en: 'Control of an Asterisk PBX' - maintainer: 'Nobody' + maintainer: 'bmxp' tester: 'Nobody' # Who tests this plugin? keywords: PBX Asterisk VOIP ISDN state: ready documentation: https://www.smarthomeng.de/user/plugins/asterisk/README.html support: https://knx-user-forum.de/forum/supportforen/smarthome-py/ - version: 1.4.1 # Plugin version + version: 1.4.2 # Plugin version sh_minversion: 1.9.0 # minimum shNG version to use this plugin # sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest) # py_minversion: 3.6 # minimum Python version to use for this plugin