From d7c5f84733bf61b1134c1ba3e403fbba6e121ac4 Mon Sep 17 00:00:00 2001 From: samson0v Date: Thu, 12 Dec 2024 10:10:28 +0200 Subject: [PATCH] Fixed BACnet error handling and getting default values from config --- thingsboard_gateway/connectors/bacnet/bacnet_connector.py | 5 ++++- .../connectors/bacnet/entities/device_object_config.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/thingsboard_gateway/connectors/bacnet/bacnet_connector.py b/thingsboard_gateway/connectors/bacnet/bacnet_connector.py index e79f367d..7033b838 100644 --- a/thingsboard_gateway/connectors/bacnet/bacnet_connector.py +++ b/thingsboard_gateway/connectors/bacnet/bacnet_connector.py @@ -153,8 +153,11 @@ async def __discover_devices(self): for device_config in self.__config.get('devices', []): try: DeviceObjectConfig.update_address_in_config_util(device_config) - await self.__application.do_who_is(device_address=device_config['address']) + result = await self.__application.do_who_is(device_address=device_config['address']) self.__log.debug('WhoIs request sent to device %s', device_config['address']) + + if result is None: + self.__log.error('Device %s not found', device_config['address']) except Exception as e: self.__log.error('Error discovering device %s: %s', device_config['address'], e) diff --git a/thingsboard_gateway/connectors/bacnet/entities/device_object_config.py b/thingsboard_gateway/connectors/bacnet/entities/device_object_config.py index ea432445..29325017 100644 --- a/thingsboard_gateway/connectors/bacnet/entities/device_object_config.py +++ b/thingsboard_gateway/connectors/bacnet/entities/device_object_config.py @@ -23,7 +23,7 @@ def __init__(self, config): self.__network_number_quality = config.get('networkNumberQuality', 'configured') self.__max_apdu_length_accepted = int(config.get('maxApduLengthAccepted', 1024)) self.__segmentation_supported = config.get('segmentationSupported', 'segmentedBoth') - self.__vendor_identifier = int(config.get('vendorIdentifier', 15)) + self.__vendor_identifier = int(config.get('vendorIdentifier', 15) or 15) @property def device_object_config(self):