From 3724f76faadb158108a0dd6cb4bd76dc3a0a8571 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Tue, 23 Nov 2021 17:33:58 +0100 Subject: [PATCH] mqtt sensor fix - mqtt sensor is now also working after changing the configuration - config.yaml accepts now also 'true' besides 'True' to activate mqtt --- cbpi/__init__.py | 2 +- cbpi/controller/satellite_controller.py | 6 ++---- cbpi/craftbeerpi.py | 2 +- cbpi/extension/mqtt_actor/__init__.py | 2 +- cbpi/extension/mqtt_sensor/__init__.py | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 128db3d..8c3a589 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.0.50" +__version__ = "4.0.0.51" diff --git a/cbpi/controller/satellite_controller.py b/cbpi/controller/satellite_controller.py index cb3a46f..4d29dda 100644 --- a/cbpi/controller/satellite_controller.py +++ b/cbpi/controller/satellite_controller.py @@ -81,11 +81,9 @@ class SatelliteController: await self.client.subscribe(topic) async for message in messages: await method(message.payload.decode()) - except asyncio.CancelledError as e: + except asyncio.CancelledError: # Cancel - self.logger.warning( - "Sub CancelledError Exception: {}".format(e)) - return + self.logger.warning("Sub Cancelled") except MqttError as e: self.logger.error("Sub MQTT Exception: {}".format(e)) except Exception as e: diff --git a/cbpi/craftbeerpi.py b/cbpi/craftbeerpi.py index 0c92028..e8a6067 100644 --- a/cbpi/craftbeerpi.py +++ b/cbpi/craftbeerpi.py @@ -113,7 +113,7 @@ class CraftBeerPi: self.upload : UploadController = UploadController(self) self.notification : NotificationController = NotificationController(self) self.satellite = None - if self.static_config.get("mqtt", False) is True: + if str(self.static_config.get("mqtt", False)).lower() == "true": self.satellite: SatelliteController = SatelliteController(self) self.dashboard = DashboardController(self) diff --git a/cbpi/extension/mqtt_actor/__init__.py b/cbpi/extension/mqtt_actor/__init__.py index 0c48ec6..76179b7 100644 --- a/cbpi/extension/mqtt_actor/__init__.py +++ b/cbpi/extension/mqtt_actor/__init__.py @@ -65,5 +65,5 @@ def setup(cbpi): :param cbpi: the cbpi core :return: ''' - if cbpi.static_config.get("mqtt", False) is True: + if str(cbpi.static_config.get("mqtt", False)).lower() == "true": cbpi.plugin.register("MQTTActor", MQTTActor) diff --git a/cbpi/extension/mqtt_sensor/__init__.py b/cbpi/extension/mqtt_sensor/__init__.py index e5267a0..4564416 100644 --- a/cbpi/extension/mqtt_sensor/__init__.py +++ b/cbpi/extension/mqtt_sensor/__init__.py @@ -58,5 +58,5 @@ def setup(cbpi): :param cbpi: the cbpi core :return: ''' - if cbpi.static_config.get("mqtt", False) is True: + if str(cbpi.static_config.get("mqtt", False)).lower() == "true": cbpi.plugin.register("MQTTSensor", MQTTSensor)