Some fixes

- command line cbpi plugins -> not interrupted if plugin has not been installed correctly
- round power value submitted by mqtt plugin
This commit is contained in:
avollkopf 2021-11-26 22:54:55 +01:00
parent b2e61bee8e
commit db39d82432
3 changed files with 13 additions and 9 deletions

View file

@ -1 +1 @@
__version__ = "4.0.0.52" __version__ = "4.0.0.54"

View file

@ -255,11 +255,15 @@ def plugins_list():
data = yaml.load(f, Loader=yaml.FullLoader) data = yaml.load(f, Loader=yaml.FullLoader)
for p in data["plugins"]: for p in data["plugins"]:
p_metadata= metadata(p) try:
p_Homepage= p_metadata['Home-page'] p_metadata= metadata(p)
p_version = p_metadata['Version'] p_Homepage= p_metadata['Home-page']
p_Author = p_metadata['Author'] p_version = p_metadata['Version']
print("- ({})\t{}".format(p_version,p)) p_Author = p_metadata['Author']
print("- ({})\t{}".format(p_version,p))
except Exception as e:
print (e)
pass
except Exception as e: except Exception as e:
print(e) print(e)
pass pass

View file

@ -10,7 +10,7 @@ class MQTTActor(CBPiActor):
# Custom property which can be configured by the user # Custom property which can be configured by the user
@action("Set Power", parameters=[Property.Number(label="Power", configurable=True,description="Power Setting [0-100]")]) @action("Set Power", parameters=[Property.Number(label="Power", configurable=True,description="Power Setting [0-100]")])
async def setpower(self,Power = 100 ,**kwargs): async def setpower(self,Power = 100 ,**kwargs):
self.power=int(Power) self.power=round(Power)
if self.power < 0: if self.power < 0:
self.power = 0 self.power = 0
if self.power > 100: if self.power > 100:
@ -29,7 +29,7 @@ class MQTTActor(CBPiActor):
if power != self.power: if power != self.power:
power = min(100, power) power = min(100, power)
power = max(0, power) power = max(0, power)
self.power = int(power) self.power = round(power)
await self.cbpi.satellite.publish(self.topic, json.dumps( await self.cbpi.satellite.publish(self.topic, json.dumps(
{"state": "on", "power": self.power}), True) {"state": "on", "power": self.power}), True)
self.state = True self.state = True
@ -49,7 +49,7 @@ class MQTTActor(CBPiActor):
return self.state return self.state
async def set_power(self, power): async def set_power(self, power):
self.power = power self.power = round(power)
if self.state == True: if self.state == True:
await self.on(power) await self.on(power)
else: else: