1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00
This commit is contained in:
zbeacon
2022-01-10 14:04:50 +02:00
6 changed files with 27 additions and 20 deletions

View File

@@ -340,17 +340,20 @@ class TBGatewayService:
self.__load_persistent_devices()
def __process_renamed_gateway_devices(self, renamed_device: dict):
log.info("Received renamed gateway device notification: %s", renamed_device)
old_device_name, new_device_name = renamed_device.popitem()
if old_device_name in list(self.__renamed_devices.values()):
device_name_key = TBUtility.get_dict_key_by_value(self.__renamed_devices, old_device_name)
else:
device_name_key = new_device_name
self.__renamed_devices[device_name_key] = new_device_name
if self.__config.get('handleDeviceRenaming', True):
log.info("Received renamed gateway device notification: %s", renamed_device)
old_device_name, new_device_name = renamed_device.popitem()
if old_device_name in list(self.__renamed_devices.values()):
device_name_key = TBUtility.get_dict_key_by_value(self.__renamed_devices, old_device_name)
else:
device_name_key = new_device_name
self.__renamed_devices[device_name_key] = new_device_name
self.__save_persistent_devices()
self.__load_persistent_devices()
log.debug("Current renamed_devices dict: %s", self.__renamed_devices)
self.__save_persistent_devices()
self.__load_persistent_devices()
log.debug("Current renamed_devices dict: %s", self.__renamed_devices)
else:
log.debug("Received renamed device notification %r, but device renaming handle is disabled", renamed_device)
def __process_remote_configuration(self, new_configuration):
if new_configuration is not None and self.__remote_configurator is not None:
@@ -999,7 +1002,7 @@ class TBGatewayService:
device_data_to_save = {
"connector": self.available_connectors[devices[device_name][0]],
"device_type": devices[device_name][1]}
if len(devices[device_name] > 2) and device_name not in self.__renamed_devices:
if len(devices[device_name]) > 2 and device_name not in self.__renamed_devices:
new_device_name = devices[device_name][2]
self.__renamed_devices[device_name] = new_device_name
self.__connected_devices[device_name] = device_data_to_save