From 0c9cf845ab6d0bbf23aca6e57df2afff299f9590 Mon Sep 17 00:00:00 2001 From: samson0v Date: Mon, 28 Oct 2024 15:27:52 +0200 Subject: [PATCH] Fixed processing gateway RPC --- thingsboard_gateway/gateway/tb_gateway_service.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/thingsboard_gateway/gateway/tb_gateway_service.py b/thingsboard_gateway/gateway/tb_gateway_service.py index 5c19e9ac..0f304216 100644 --- a/thingsboard_gateway/gateway/tb_gateway_service.py +++ b/thingsboard_gateway/gateway/tb_gateway_service.py @@ -1560,13 +1560,14 @@ def __rpc_gateway_processing(self, request_id, content): log.info("Received RPC request to the gateway, id: %s, method: %s", str(request_id), content["method"]) arguments = content.get('params', {}) method_to_call = content["method"].replace("gateway_", "") - result = None + if self.__remote_shell is not None: method_function = self.__remote_shell.shell_commands.get(method_to_call, self.__gateway_rpc_methods.get(method_to_call)) else: log.info("Remote shell is disabled.") method_function = self.__gateway_rpc_methods.get(method_to_call) + if method_function is None and method_to_call in self.__rpc_scheduled_methods_functions: seconds_to_restart = arguments * 1000 if arguments and arguments != '{}' else 0 self.__scheduled_rpc_calls.append([time() * 1000 + seconds_to_restart, @@ -1578,10 +1579,11 @@ def __rpc_gateway_processing(self, request_id, content): return {"error": "Method not found", "code": 404} elif isinstance(arguments, list): result = method_function(*arguments) - elif arguments: - result = method_function(arguments) - else: + elif arguments == '{}' or arguments is None: result = method_function() + else: + result = method_function(arguments) + return result @staticmethod