mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Minor improvements
This commit is contained in:
@@ -133,10 +133,16 @@ class TBClient(threading.Thread):
|
||||
if credentials.get("clientId") is not None:
|
||||
self.__client_id = str(credentials["clientId"])
|
||||
|
||||
rate_limits_config = {}
|
||||
if self.__config.get('rateLimits'):
|
||||
rate_limits_config['rate_limit'] = self.__config['rateLimits']
|
||||
if self.__config.get('dpRateLimits'):
|
||||
rate_limits_config['dp_rate_limit'] = self.__config['dpRateLimits']
|
||||
|
||||
if rate_limits_config:
|
||||
self.client = TBGatewayMqttClient(self.__host, self.__port, self.__username, self.__password, self,
|
||||
quality_of_service=self.__default_quality_of_service,
|
||||
client_id=self.__client_id, rate_limit=self.__config['rateLimits'])
|
||||
client_id=self.__client_id, **rate_limits_config)
|
||||
else:
|
||||
self.client = TBGatewayMqttClient(self.__host, self.__port, self.__username, self.__password, self,
|
||||
quality_of_service=self.__default_quality_of_service,
|
||||
|
||||
@@ -141,6 +141,8 @@ def get_env_variables():
|
||||
env_variables['password'] = environ.get('TB_GW_PASSWORD')
|
||||
if environ.get('TB_GW_RATE_LIMITS'):
|
||||
env_variables['rateLimits'] = environ.get('TB_GW_RATE_LIMITS')
|
||||
if environ.get('TB_GW_DP_RATE_LIMITS'):
|
||||
env_variables['dpRateLimits'] = environ.get('TB_GW_DP_RATE_LIMITS')
|
||||
|
||||
converted_env_variables = {}
|
||||
|
||||
@@ -1521,7 +1523,10 @@ class TBGatewayService:
|
||||
|
||||
def del_device(self, device_name):
|
||||
if device_name in self.__connected_devices:
|
||||
self.tb_client.client.gw_disconnect_device(device_name)
|
||||
try:
|
||||
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)
|
||||
self.__saved_devices.pop(device_name)
|
||||
self.__save_persistent_devices()
|
||||
|
||||
Reference in New Issue
Block a user