Skip to content

Commit 865f3ee

Browse files
authored
Merge pull request #1949 from Andry925/fix/add-more-robust-logs-on-bacnet-rpc
Added more explicit log handling
2 parents cd873fa + 9af6655 commit 865f3ee

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

thingsboard_gateway/connectors/bacnet/bacnet_connector.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ async def __read_property(self, address, object_id, property_id):
581581
result = await self.__application.read_property(address, object_id, property_id)
582582
return {"value": str(result)}
583583
except ErrorRejectAbortNack as err:
584-
return Exception({"error": str(err)})
584+
return {"error": str(err)}
585585
except Exception as e:
586586
result = {}
587587
self.__log.error('Error reading property %s:%s from device %s: %s', object_id, property_id, address, e)
@@ -905,8 +905,16 @@ def __process_rpc(self, rpc_method_name, rpc_config, content, device):
905905
device.name,
906906
)
907907
result = {"error": f"Timeout rpc has been reached for {device.name}"}
908+
908909
elif task_completed:
909-
self.__log.info('Processed RPC request with result: %r', result)
910+
if result.get("response", {}).get("value", {}):
911+
self.__log.info('Processed RPC request with result: %s', result)
912+
else:
913+
self.__log.error(
914+
"An error occurred during RPC request: %s",
915+
result.get('response', {}).get('error', '')
916+
)
917+
910918
self.__gateway.send_rpc_reply(device=device.device_info.device_name,
911919
req_id=content['data'].get('id'),
912920
content={'result': str(result.get('response'))})

0 commit comments

Comments
 (0)