From 80bdac45ce3cb5874ce91bb1d156ea1a0ce8ab7d Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Thu, 2 Dec 2021 14:48:39 +0100 Subject: [PATCH] some fixes for actor power - Actor used to set power to 100 eventhough target was 0 - moved chromium.desktop file to config folder -> easier available for users and potential to enable chromium desktop via cbpi commandline in future --- cbpi/__init__.py | 2 +- cbpi/config/chromium.desktop | 6 ++++++ cbpi/controller/actor_controller.py | 9 +++++++-- cbpi/extension/gpioactor/__init__.py | 11 +++++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 cbpi/config/chromium.desktop diff --git a/cbpi/__init__.py b/cbpi/__init__.py index c45fc4e..db205e1 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.0.54" +__version__ = "4.0.0.55" diff --git a/cbpi/config/chromium.desktop b/cbpi/config/chromium.desktop new file mode 100644 index 0000000..a112515 --- /dev/null +++ b/cbpi/config/chromium.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=Chromium +Comment=Chromium Webbrowser +NoDisplay=false +Exec=chromium-browser --noerrordialogs --disable-session-crashed-bubble --disable-infobars --force-device-scale-factor=1.00 --start-fullscreen "http://localhost:8000" diff --git a/cbpi/controller/actor_controller.py b/cbpi/controller/actor_controller.py index aade888..dca5a44 100644 --- a/cbpi/controller/actor_controller.py +++ b/cbpi/controller/actor_controller.py @@ -9,10 +9,15 @@ class ActorController(BasicController): self.update_key = "actorupdate" async def on(self, id, power=None): + logging.info("Controller_power: {}".format(power)) try: item = self.find_by_id(id) - if item.power: - power = item.power + if power is None: + logging.info("Power is none") + if item.power: + power = item.power + else: + power = 100 if item.instance.state is False: await item.instance.on(power) await self.push_udpate() diff --git a/cbpi/extension/gpioactor/__init__.py b/cbpi/extension/gpioactor/__init__.py index 32b9add..191aa43 100644 --- a/cbpi/extension/gpioactor/__init__.py +++ b/cbpi/extension/gpioactor/__init__.py @@ -48,7 +48,7 @@ class GPIOActor(CBPiActor): return 0 if self.inverted == False else 1 async def on_start(self): - self.power = 100 + self.power = None self.gpio = self.props.GPIO self.inverted = True if self.props.get("Inverted", "No") == "Yes" else False self.sampleTime = int(self.props.get("SamplingTime", 5)) @@ -59,6 +59,8 @@ class GPIOActor(CBPiActor): async def on(self, power = None): if power is not None: self.power = power + else: + self.power = 100 await self.set_power(self.power) logger.info("ACTOR %s ON - GPIO %s " % (self.id, self.gpio)) @@ -116,13 +118,18 @@ class GPIOPWMActor(CBPiActor): GPIO.setup(self.gpio, GPIO.OUT) GPIO.output(self.gpio, 0) self.state = False - self.power = 100 + self.power = None self.p = None pass async def on(self, power = None): + logging.info("PWM Actor Power: {}".format(power)) if power is not None: self.power = power + else: + self.power = 100 + + logging.info("PWM Final Power: {}".format(self.power)) logger.info("PWM ACTOR %s ON - GPIO %s - Frequency %s - Power %s" % (self.id, self.gpio,self.frequency,self.power)) try: