From c6d629659bb0e1c1e49435ab1b90a66badb67482 Mon Sep 17 00:00:00 2001 From: Arksine Date: Tue, 27 Oct 2020 09:09:59 -0400 Subject: [PATCH] klippy_apis: Add API to register methods with Klippy Signed-off-by: Eric Callahan --- moonraker/plugins/klippy_apis.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/moonraker/plugins/klippy_apis.py b/moonraker/plugins/klippy_apis.py index a7ac505..84e5f44 100644 --- a/moonraker/plugins/klippy_apis.py +++ b/moonraker/plugins/klippy_apis.py @@ -13,6 +13,7 @@ GCODE_ENDPOINT = "gcode/script" SUBSCRIPTION_ENDPOINT = "objects/subscribe" STATUS_ENDPOINT = "objects/query" OBJ_LIST_ENDPOINT = "objects/list" +REG_METHOD_ENDPOINT = "register_remote_method" class Sentinel: pass @@ -129,5 +130,11 @@ class KlippyAPI: return await self._send_klippy_request( GC_OUTPUT_ENDPOINT, template, default) + async def register_method(self, method_name): + return await self._send_klippy_request( + REG_METHOD_ENDPOINT, + {'response_template': {"method": method_name}, + 'remote_method': method_name}) + def load_plugin(config): return KlippyAPI(config)