From fa301d1ad61f1a6d860fa6c2895e96027fcf95b4 Mon Sep 17 00:00:00 2001 From: rospogrigio Date: Tue, 7 Feb 2023 17:19:27 +0100 Subject: [PATCH] Fix for not reconnecting after 'giving up' --- custom_components/localtuya/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index 36d9104f9..cd503c2af 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -234,7 +234,10 @@ async def _make_connection(self): self.status_updated(status) else: self.error("Initial state update failed, giving up: %r", ex) - # return + if self._interface is not None: + await self._interface.close() + self._interface = None + except (UnicodeDecodeError, json.decoder.JSONDecodeError) as ex: self.warning("Initial state update failed (%s), trying key update", ex) await self.update_local_key()