From 10da707ae1997c7bfb447ad3c215d3ccbb0e494c Mon Sep 17 00:00:00 2001 From: Bander <46300268+xZetsubou@users.noreply.github.com> Date: Sun, 7 Jan 2024 01:01:48 +0300 Subject: [PATCH] Fix: reconnecting sub-devices --- custom_components/localtuya/common.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index 56c8535be..84002e731 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -243,12 +243,9 @@ async def _make_connection(self): retry += 1 try: if self.is_subdevice: - await self.get_gateway() - gateway = self._gwateway - # if not gateway or not (gateway.connected and gateway.is_connecting): - # return await self.abort_connect() - if gateway and gateway.is_connecting: - await gateway._connect_task + gateway = await self.get_gateway() + if not gateway or (not gateway.connected or gateway.is_connecting): + return await self.abort_connect() self._interface = gateway._interface else: self._interface = await pytuya.connect(