From aa76c908ef1b132bd1bf4dc3c14797a89ae22768 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Wed, 9 Mar 2022 08:25:17 +0100 Subject: [PATCH] wlan0 speed fix for linux / defalt mqtt actor off on startup --- cbpi/__init__.py | 2 +- cbpi/controller/system_controller.py | 8 +++++--- cbpi/extension/mqtt_actor/mqtt_actor.py | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 2a547cd..a48bba4 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.2.0.a18" +__version__ = "4.0.2.0.a19" diff --git a/cbpi/controller/system_controller.py b/cbpi/controller/system_controller.py index af3c8a0..59a6eae 100644 --- a/cbpi/controller/system_controller.py +++ b/cbpi/controller/system_controller.py @@ -237,9 +237,11 @@ class SystemController: else: eth0speed = "down" if nic == 'wlan0': - if info[nic].isup == True: - if info[nic].speed: - wlan0speed = info[nic].speed + if info[nic].isup == True: + ratestring = os.popen('iwlist wlan0 rate | grep Rate').read() + start = ratestring.find("=") + 1 + end = ratestring.find(" Mb/s") + wlan0speed = ratestring[start:end] else: wlan0speed = "down" except Exception as e: diff --git a/cbpi/extension/mqtt_actor/mqtt_actor.py b/cbpi/extension/mqtt_actor/mqtt_actor.py index 5788c12..28dd198 100644 --- a/cbpi/extension/mqtt_actor/mqtt_actor.py +++ b/cbpi/extension/mqtt_actor/mqtt_actor.py @@ -22,6 +22,8 @@ class MQTTActor(CBPiActor): async def on_start(self): self.topic = self.props.get("Topic", None) self.power = 100 + await self.off() + self.state = False async def on(self, power=None): if power is not None: