Skip to content

Commit 9af6655

Browse files
committed
add more explicit log handling for bacnet rpc
1 parent 25cbee5 commit 9af6655

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
@@ -527,7 +527,7 @@ async def __read_property(self, address, object_id, property_id):
527527
result = await self.__application.read_property(address, object_id, property_id)
528528
return {"value": str(result)}
529529
except ErrorRejectAbortNack as err:
530-
return Exception({"error": str(err)})
530+
return {"error": str(err)}
531531
except Exception as e:
532532
result = {}
533533
self.__log.error('Error reading property %s:%s from device %s: %s', object_id, property_id, address, e)
@@ -851,8 +851,16 @@ def __process_rpc(self, rpc_method_name, rpc_config, content, device):
851851
device.name,
852852
)
853853
result = {"error": f"Timeout rpc has been reached for {device.name}"}
854+
854855
elif task_completed:
855-
self.__log.info('Processed RPC request with result: %r', result)
856+
if result.get("response", {}).get("value", {}):
857+
self.__log.info('Processed RPC request with result: %s', result)
858+
else:
859+
self.__log.error(
860+
"An error occurred during RPC request: %s",
861+
result.get('response', {}).get('error', '')
862+
)
863+
856864
self.__gateway.send_rpc_reply(device=device.device_info.device_name,
857865
req_id=content['data'].get('id'),
858866
content={'result': str(result.get('response'))})

0 commit comments

Comments
 (0)