Skip to content

Commit

Permalink
Merge pull request #1238 from samson0v/master
Browse files Browse the repository at this point in the history
Optimize attribute parse method
  • Loading branch information
imbeacon authored Nov 23, 2023
2 parents c4ded48 + e5c0039 commit b9148fb
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,14 @@ def _attributes_parse(self, content, *args):
log.debug("Received data: %s", content)
if content is not None:
shared_attributes = content.get("shared", {})
client_attributes = content.get("client", {})
if shared_attributes or client_attributes:
self.__process_attributes_response(shared_attributes, client_attributes)
else:
self.__process_attribute_update(content)

# client attributes now required for now, can be used in future
# client_attributes = content.get("client", {})

if shared_attributes:
self.__process_attribute_update(shared_attributes)
log.debug("Shared attributes received (%s).",
", ".join([attr for attr in shared_attributes.keys()]))
if client_attributes:
log.debug("Client attributes received (%s).",
", ".join([attr for attr in client_attributes.keys()]))
except Exception as e:
log.exception(e)

Expand All @@ -557,10 +553,6 @@ def __process_attribute_update(self, content):
self.__process_remote_configuration(content)
self.__process_remote_converter_configuration_update(content)

def __process_attributes_response(self, shared_attributes, client_attributes):
self.__process_remote_logging_update(shared_attributes.get('RemoteLoggingLevel'))
self.__process_remote_configuration(shared_attributes)

def __process_remote_logging_update(self, remote_logging_level):
if remote_logging_level == 'NONE':
self.remote_handler.deactivate()
Expand Down

0 comments on commit b9148fb

Please sign in to comment.