Skip to content

Commit

Permalink
Merge pull request #1076 from samson0v/master
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Mar 14, 2023
2 parents 83ce43b + 93b7727 commit dd97ead
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _watchers(self):
if self.tb_client.is_connected() and not self.__subscribed_to_rpc_topics:
for device in self.__saved_devices:
self.add_device(device, {"connector": self.__saved_devices[device]["connector"]},
device_type=self.__saved_devices[device]["device_type"])
device_type=self.__saved_devices[device]["device_type"], reconnect=True)
self.subscribe_to_required_topics()
self.__subscribed_to_rpc_topics = True

Expand Down Expand Up @@ -1189,8 +1189,8 @@ def add_device_async(self, data):
else:
return Status.FAILURE

def add_device(self, device_name, content, device_type=None):
if device_name not in self.__saved_devices:
def add_device(self, device_name, content, device_type=None, reconnect=False):
if device_name not in self.__saved_devices or reconnect:
device_type = device_type if device_type is not None else 'default'
self.__connected_devices[device_name] = {**content, "device_type": device_type}
self.__saved_devices[device_name] = {**content, "device_type": device_type}
Expand Down

0 comments on commit dd97ead

Please sign in to comment.