Skip to content

Commit

Permalink
Merge branch 'thingsboard:master' into modificationConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanlr authored Oct 28, 2024
2 parents 302684a + acb75f0 commit 093c77c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions thingsboard_gateway/connectors/mqtt/mqtt_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ def __init__(self, gateway, config, connector_type):
self._mqtt_version = self.__broker.get('version', 5)
try:
if self._mqtt_version != 5:
self._client = Client(client_id, clean_session=self._cleanSession, protocol=MQTT_VERSIONS[self._mqtt_version])
self._client = Client(client_id=client_id, clean_session=self._cleanSession,
protocol=MQTT_VERSIONS[self._mqtt_version])
else:
self._client = Client(client_id, protocol=MQTT_VERSIONS[self._mqtt_version])
self._client = Client(client_id=client_id, protocol=MQTT_VERSIONS[self._mqtt_version])
except KeyError:
self.__log.error('Unknown MQTT version. Starting up on version 5...')
self._client = Client(client_id, protocol=MQTTv5)
self._client = Client(client_id=client_id, protocol=MQTTv5)
self._mqtt_version = 5

self.name = config.get("name", self.__broker.get(
Expand Down
5 changes: 5 additions & 0 deletions thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ def __process_deleted_gateway_devices(self, deleted_device_name: str):
if deleted_device_name in self.__saved_devices:
del self.__saved_devices[deleted_device_name]
log.debug("Device %s - was removed from __saved_devices", deleted_device_name)
if deleted_device_name in self.__added_devices:
del self.__added_devices[deleted_device_name]
log.debug("Device %s - was removed from __added_devices", deleted_device_name)
if hasattr(self, "__duplicate_detector"):
self.__duplicate_detector.delete_device(deleted_device_name)
self.__save_persistent_devices()
Expand Down Expand Up @@ -1770,8 +1773,10 @@ def del_device(self, device_name):
self.tb_client.client.gw_disconnect_device(device_name)
except Exception as e:
log.exception("Error on disconnecting device %s", device_name, exc_info=e)

self.__connected_devices.pop(device_name, None)
self.__saved_devices.pop(device_name, None)
self.__added_devices.pop(device_name, None)
self.__save_persistent_devices()

def get_devices(self, connector_id: str = None):
Expand Down

0 comments on commit 093c77c

Please sign in to comment.