@@ -223,6 +223,7 @@ async def _make_connection(self):
223
223
if self ._fake_gateway :
224
224
self .warning (f"Failed to use { name } as gateway." )
225
225
await self .abort_connect ()
226
+ update_localkey = True
226
227
227
228
if self ._interface is not None :
228
229
# Attempt to restore status for all entities that need to first set
@@ -308,6 +309,8 @@ async def close(self):
308
309
async def update_local_key (self ):
309
310
"""Retrieve updated local_key from Cloud API and update the config_entry."""
310
311
dev_id = self ._device_config .id
312
+ name = self ._device_config .name
313
+
311
314
cloud_api = self ._hass_entry .cloud_data
312
315
await cloud_api .async_get_devices_list ()
313
316
discovery = self ._hass .data [DOMAIN ].get (DATA_DISCOVERY )
@@ -330,21 +333,22 @@ async def update_local_key(self):
330
333
331
334
# Update Gateway ID and IP
332
335
if new_gw := get_gateway_by_deviceid (dev_id , cloud_devs ):
336
+ self .info (f"Updated { name } gateway ID to: { new_gw .id } " )
333
337
new_data [CONF_DEVICES ][dev_id ][CONF_GATEWAY_ID ] = new_gw .id
334
- self . info ( f"Updated { dev_id } gateway ID to: { new_gw . id } " )
338
+
335
339
if discovery and (local_gw := discovery .devices .get (new_gw .id )):
336
340
new_ip = local_gw .get (CONF_TUYA_IP , self ._device_config .host )
337
341
new_data [CONF_DEVICES ][dev_id ][CONF_HOST ] = new_ip
338
- self .info (f"Updated { dev_id } IP to: { new_ip } " )
342
+ self .info (f"Updated { name } IP to: { new_ip } " )
339
343
340
- self .info (f"Updated informations for sub-device { dev_id } ." )
344
+ self .info (f"Updated informations for sub-device { name } ." )
341
345
342
346
new_data [CONF_DEVICES ][dev_id ][CONF_LOCAL_KEY ] = self ._local_key
343
347
new_data [ATTR_UPDATED_AT ] = str (int (time .time () * 1000 ))
344
348
self ._hass .config_entries .async_update_entry (
345
349
self ._config_entry , data = new_data
346
350
)
347
- self .info (f"local_key updated for device { dev_id } ." )
351
+ self .info (f"local_key updated for device { name } ." )
348
352
349
353
async def set_values (self ):
350
354
"""Send self._pending_status payload to device."""
0 commit comments