1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Added synchronizing method for converters config

This commit is contained in:
samson0v
2023-05-03 11:03:48 +03:00
parent ded7ae7e04
commit 7b1d93959d
2 changed files with 7 additions and 4 deletions

View File

@@ -442,7 +442,7 @@ class MqttConnector(Connector, Thread):
else:
self.__log.error("%s connection FAIL with unknown error!", self.get_name())
self._send_current_converter_config()
self._init_send_current_converter_config()
def _on_disconnect(self, *args):
self._connected = False
@@ -882,6 +882,7 @@ class MqttConnector(Connector, Thread):
converter_obj = converter_class_obj
if converter_class_name == converter_name:
converter_obj.config = config
self._send_current_converter_config(self.name + ':' + converter_name, config)
log.info('Updated converter configuration for: %s with configuration %s',
converter_name, converter_obj.config)
@@ -891,14 +892,14 @@ class MqttConnector(Connector, Thread):
device_config['converter'].update(config)
if device_config['converter']['deviceNameTopicExpression'] == config[
'deviceNameTopicExpression']:
'deviceNameTopicExpression']:
device_config['converter'].update(config)
except KeyError:
continue
self.__gateway.update_connector_config_file(self.name, self.config)
def _send_current_converter_config(self):
def _init_send_current_converter_config(self):
for converter_obj in self.get_converters():
try:
self.__gateway.tb_client.client.send_attributes(
@@ -906,6 +907,9 @@ class MqttConnector(Connector, Thread):
except AttributeError:
continue
def _send_current_converter_config(self, name, config):
self.__gateway.tb_client.client.send_attributes({name: config})
class ConverterWorker(Thread):
def __init__(self, name, incoming_queue, send_result):
super().__init__()

View File

@@ -948,7 +948,6 @@ class TBGatewayService:
while self.__rpc_reply_sent:
sleep(.2)
self.__send_data(devices_data_in_event_pack)
sleep(self.__min_pack_send_delay_ms)
if self.tb_client.is_connected() and (
self.__remote_configurator is None or not self.__remote_configurator.in_process):