diff --git a/socket_example.py b/socket_example.py new file mode 100644 index 000000000..e69de29bb diff --git a/thingsboard_gateway/connectors/socket/socket_connector.py b/thingsboard_gateway/connectors/socket/socket_connector.py index db4c40664..cbf01f228 100644 --- a/thingsboard_gateway/connectors/socket/socket_connector.py +++ b/thingsboard_gateway/connectors/socket/socket_connector.py @@ -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 @@ -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) @@ -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', [])