diff --git a/custom_components/xiaomi_gateway3/core/gateway3.py b/custom_components/xiaomi_gateway3/core/gateway3.py index 7700bdfc..c154efb7 100644 --- a/custom_components/xiaomi_gateway3/core/gateway3.py +++ b/custom_components/xiaomi_gateway3/core/gateway3.py @@ -147,8 +147,12 @@ def _prepeare_gateway(self, with_devices: bool = False): self.debug("Stop Lumi Zigbee") shell.stop_lumi_zigbee() - elif "Lumi_Z3GatewayHost_MQTT" not in ps: - shell.run_lumi_zigbee() + else: + if "socat" in ps: + shell.stop_socat() + + if "Lumi_Z3GatewayHost_MQTT" not in ps: + shell.run_lumi_zigbee() # elif "Lumi_Z3GatewayHost_MQTT -n 1 -b 115200 -v" not in ps: # self.debug("Run public Zigbee console") # shell.run_public_zb_console() diff --git a/custom_components/xiaomi_gateway3/core/shell.py b/custom_components/xiaomi_gateway3/core/shell.py index 93faa6ad..54739ad4 100644 --- a/custom_components/xiaomi_gateway3/core/shell.py +++ b/custom_components/xiaomi_gateway3/core/shell.py @@ -40,6 +40,9 @@ def check_or_download_socat(self): def run_socat(self): self.exec(f"{CHECK_SOCAT} && {RUN_SOCAT}") + def stop_socat(self): + self.exec(f"killall socat") + def run_lumi_zigbee(self): self.exec("daemon_app.sh &")