Skip to content

Commit

Permalink
Fix for bad report strategy overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Sep 18, 2024
1 parent dd6805e commit a008d28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions thingsboard_gateway/connectors/modbus/modbus_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ def __add_slave_to_devices(self):

def __load_slaves(self):
for device in self.__config.get('master', {'slaves': []}).get('slaves', []):
self.__slaves.append(Slave(**{**device, 'connector': self, 'gateway': self.__gateway, 'logger': self.__log,
'callback': ModbusConnector.callback, REPORT_STRATEGY_PARAMETER: self.__main_report_strategy}))
slave_config = {**device, 'connector': self, 'gateway': self.__gateway, 'logger': self.__log,
'callback': ModbusConnector.callback}
if REPORT_STRATEGY_PARAMETER not in slave_config:
slave_config[REPORT_STRATEGY_PARAMETER] = self.__main_report_strategy
self.__slaves.append(Slave(**slave_config))

@classmethod
def callback(cls, slave: Slave, request_type: RequestType, data=None):
Expand Down
2 changes: 1 addition & 1 deletion thingsboard_gateway/connectors/modbus/slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def timer(self):
if current_monotonic - self.__last_polled_time >= self.poll_period:
self.callback(self, RequestType.POLL)
self.__last_polled_time = current_monotonic
if current_monotonic - self.__last_checked_time >= 1:
if current_monotonic - self.__last_checked_time >= 1.0:
self.__check_data_to_send_periodically(current_monotonic)
self.__last_checked_time = current_monotonic
except Exception as e:
Expand Down

0 comments on commit a008d28

Please sign in to comment.