From e1e7a28933cda09dc1d71f7735303730c0693342 Mon Sep 17 00:00:00 2001 From: oven-lab Date: Wed, 24 May 2023 20:09:54 +0200 Subject: [PATCH 1/3] Fix addr: prefix Tuya vaccum by Elvita returns "addr:" before the ip address. This makes HA try to connect to a non-existing dns address. Thus, resulting in an error. Pretty hacky fix, but it shouldn't disturb any other devices. --- custom_components/localtuya/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index cd503c2af..3525f2446 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -184,6 +184,9 @@ def async_connect(self): async def _make_connection(self): """Subscribe localtuya entity events.""" self.info("Trying to connect to %s...", self._dev_config_entry[CONF_HOST]) + + if "addr:" in self._dev_config_entry[CONF_HOST]: + self._dev_config_entry[CONF_HOST] = self._dev_config_entry[CONF_HOST].replace("addr:","") try: self._interface = await pytuya.connect( From 21c4bf5ab66cae37e66a7cf334c4c80c64eee843 Mon Sep 17 00:00:00 2001 From: oven-lab Date: Sun, 28 May 2023 21:06:26 +0200 Subject: [PATCH 2/3] Update common.py TOX fixes --- custom_components/localtuya/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index 3525f2446..05449b982 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -184,9 +184,9 @@ def async_connect(self): async def _make_connection(self): """Subscribe localtuya entity events.""" self.info("Trying to connect to %s...", self._dev_config_entry[CONF_HOST]) - + if "addr:" in self._dev_config_entry[CONF_HOST]: - self._dev_config_entry[CONF_HOST] = self._dev_config_entry[CONF_HOST].replace("addr:","") + self._dev_config_entry[CONF_HOST] = self._dev_config_entry[CONF_HOST].replace("addr:", "") try: self._interface = await pytuya.connect( From d364186f15815e2601e213169867e1ab5222ed0c Mon Sep 17 00:00:00 2001 From: oven-lab Date: Mon, 29 May 2023 14:18:59 +0200 Subject: [PATCH 3/3] Tox fix --- custom_components/localtuya/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index 05449b982..e5ab5aac0 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -186,7 +186,9 @@ async def _make_connection(self): self.info("Trying to connect to %s...", self._dev_config_entry[CONF_HOST]) if "addr:" in self._dev_config_entry[CONF_HOST]: - self._dev_config_entry[CONF_HOST] = self._dev_config_entry[CONF_HOST].replace("addr:", "") + self._dev_config_entry[CONF_HOST] = self._dev_config_entry[ + CONF_HOST + ].replace("addr:", "") try: self._interface = await pytuya.connect(