Skip to content

Commit

Permalink
Merge pull request #1424 from samson0v/master
Browse files Browse the repository at this point in the history
Fixed Socket connector data processing
  • Loading branch information
imbeacon authored Jun 11, 2024
2 parents 8478384 + 2dde76b commit 63ffd23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Empty file added socket_example.py
Empty file.
9 changes: 8 additions & 1 deletion thingsboard_gateway/connectors/socket/socket_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import socket
from queue import Queue
from random import choice
from re import findall, fullmatch, compile
from re import findall, compile, fullmatch
from string import ascii_lowercase
from threading import Thread
from time import sleep
Expand Down Expand Up @@ -69,6 +69,11 @@ def __convert_devices_list(self):
converters_for_devices = {}
for device in devices:
address = device.get('addressFilter', device.get('address', None))
if address is None:
self.__log.error('Device %s has no addressFilter or address', device.get('deviceName', 'Unknown'))
continue

address = address.replace('*', '.*')
address_key = address
try:
address_key = compile(address)
Expand Down Expand Up @@ -209,6 +214,8 @@ def __process_data(self):
if client_address != conf_device_address and not fullmatch(conf_device_address, client_address):
continue
device = self.__devices.get(conf_device_address)
device['address'] = client_address

# check data for attribute requests
is_attribute_request = False
attr_requests = device.get('attributeRequests', [])
Expand Down

0 comments on commit 63ffd23

Please sign in to comment.