Skip to content

Commit c82dc11

Browse files
committed
Update localkey on other type of errors rospogrigio#194
1 parent 6c68494 commit c82dc11

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

custom_components/localtuya/common.py

+5
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ async def _make_connection(self):
294294
await self.abort_connect()
295295
if not retry < self._connect_max_tries and not self.is_sleep:
296296
self.warning(f"Failed to connect to {host}: {str(ex)}")
297+
if "key" in str(ex):
298+
await self.update_local_key()
297299

298300
if self._interface is not None:
299301
try:
@@ -435,9 +437,12 @@ async def update_local_key(self):
435437
# Update Gateway ID and IP
436438
new_gw = get_gateway_by_deviceid(dev_id, cloud_devs)
437439
new_data[CONF_DEVICES][dev_id][CONF_GATEWAY_ID] = new_gw.id
440+
self.info(f"{dev_id} new gateway ID: {new_gw.id}")
438441
if discovery and (local_gw := discovery.devices.get(new_gw.id)):
439442
new_ip = local_gw.get(CONF_TUYA_IP, self._device_config.host)
440443
new_data[CONF_DEVICES][dev_id][CONF_HOST] = new_ip
444+
self.info(f"Updated {dev_id} IP: {new_ip}")
445+
441446
self.info(f"Updated informations for sub-device {dev_id}.")
442447

443448
new_data[CONF_DEVICES][dev_id][CONF_LOCAL_KEY] = self._local_key

0 commit comments

Comments
 (0)