From db39d8243258edb95ca691c37ddc3f5c14e561c3 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Fri, 26 Nov 2021 22:54:55 +0100 Subject: [PATCH] Some fixes - command line cbpi plugins -> not interrupted if plugin has not been installed correctly - round power value submitted by mqtt plugin --- cbpi/__init__.py | 2 +- cbpi/cli.py | 14 +++++++++----- cbpi/extension/mqtt_actor/__init__.py | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 4618101..c45fc4e 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.0.52" +__version__ = "4.0.0.54" diff --git a/cbpi/cli.py b/cbpi/cli.py index 5b0b4fd..7552600 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -255,11 +255,15 @@ def plugins_list(): data = yaml.load(f, Loader=yaml.FullLoader) for p in data["plugins"]: - p_metadata= metadata(p) - p_Homepage= p_metadata['Home-page'] - p_version = p_metadata['Version'] - p_Author = p_metadata['Author'] - print("- ({})\t{}".format(p_version,p)) + try: + p_metadata= metadata(p) + p_Homepage= p_metadata['Home-page'] + p_version = p_metadata['Version'] + p_Author = p_metadata['Author'] + print("- ({})\t{}".format(p_version,p)) + except Exception as e: + print (e) + pass except Exception as e: print(e) pass diff --git a/cbpi/extension/mqtt_actor/__init__.py b/cbpi/extension/mqtt_actor/__init__.py index 76179b7..b7e8cf1 100644 --- a/cbpi/extension/mqtt_actor/__init__.py +++ b/cbpi/extension/mqtt_actor/__init__.py @@ -10,7 +10,7 @@ class MQTTActor(CBPiActor): # Custom property which can be configured by the user @action("Set Power", parameters=[Property.Number(label="Power", configurable=True,description="Power Setting [0-100]")]) async def setpower(self,Power = 100 ,**kwargs): - self.power=int(Power) + self.power=round(Power) if self.power < 0: self.power = 0 if self.power > 100: @@ -29,7 +29,7 @@ class MQTTActor(CBPiActor): if power != self.power: power = min(100, power) power = max(0, power) - self.power = int(power) + self.power = round(power) await self.cbpi.satellite.publish(self.topic, json.dumps( {"state": "on", "power": self.power}), True) self.state = True @@ -49,7 +49,7 @@ class MQTTActor(CBPiActor): return self.state async def set_power(self, power): - self.power = power + self.power = round(power) if self.state == True: await self.on(power) else: