aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/API_Server.md30
-rw-r--r--docs/Command_Templates.md4
2 files changed, 34 insertions, 0 deletions
diff --git a/docs/API_Server.md b/docs/API_Server.md
index bb46ce8f..c874365e 100644
--- a/docs/API_Server.md
+++ b/docs/API_Server.md
@@ -146,6 +146,36 @@ transition to a "shutdown" state. It behaves similarly to the G-Code
`M112` command. For example:
`{"id": 123, "method": "emergency_stop"}`
+### register_remote_method
+
+This endpoint allows clients to register methods that can be called
+from klipper. It will return an empty object upon success.
+
+For example:
+`{"id": 123, "method": "register_remote_method",
+"params": {"response_template": {"action": "run_paneldue_beep"},
+"remote_method": "paneldue_beep"}}`
+will return:
+`{"id": 123, "result": {}}`
+
+The remote method `paneldue_beep` may now be called from Klipper. Note
+that if the method takes parameters they should be provided as keyword
+arguments. Below is an example of how it may called from a gcode_macro:
+```
+[gcode_macro PANELDUE_BEEP]
+default_parameter_FREQUENCY: 300
+default_parameter_DURATION: 1.
+gcode:
+ {action_call_remote_method("paneldue_beep",
+ frequency=FREQUENCY|int,
+ duration=DURATION|float)}
+```
+
+When the PANELDUE_BEEP gcode macro is executed, Klipper would send something
+like the following over the socket:
+`{"action": "run_paneldue_beep",
+"params": {"frequency": 300, "duration": 1.0}}
+
### objects/list
This endpoint queries the list of available printer "objects" that one
diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md
index 0160796f..fe2ff2c9 100644
--- a/docs/Command_Templates.md
+++ b/docs/Command_Templates.md
@@ -305,6 +305,10 @@ Available "action" commands:
- `action_emergency_stop(msg)`: Transition the printer to a shutdown
state. The `msg` parameter is optional, it may be useful to describe
the reason for the shutdown.
+- `action_call_remote_method(method_name)`: Calls a method registered
+ by a remote client. If the method takes parameters they should
+ be provided via keyword arguments, ie:
+ `action_call_remote_method("print_stuff", my_arg="hello_world")`
### Variables