Skip to content

Commit

Permalink
✨ Lights toggle API command
Browse files Browse the repository at this point in the history
  • Loading branch information
cp2004 committed Oct 1, 2021
1 parent 98f7d2c commit 4f247c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/documentation/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ See also the [SimpleApi docs](https://docs.octoprint.org/en/devel/plugins/mixins
| :--- | :--- | :--- |
| `lights_on` | None | Turn the LEDs on |
| `lights_off` | None | Turn the LEDs off |
| `lights_toggle` | None | Toggle the LED state |
| `torch_on` | None | Turn the torch mode on |
| `torch_off` | None | Turn the torch mode off. Only available if torch mode is configured as toggle. |
| `test_os_config` | None | Begin an OS configuration test. Asynchronous, data is returned on the socket |
Expand Down
4 changes: 4 additions & 0 deletions octoprint_ws281x_led_status/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Define API commands
CMD_LIGHTS_ON = "lights_on"
CMD_LIGHTS_OFF = "lights_off"
CMD_LIGHTS_TOGGLE = "lights_toggle"
CMD_TORCH_ON = "torch_on"
CMD_TORCH_OFF = "torch_off"
CMD_TEST_OS = "test_os_config"
Expand All @@ -33,6 +34,7 @@ def get_api_commands():
return {
CMD_LIGHTS_ON: [],
CMD_LIGHTS_OFF: [],
CMD_LIGHTS_TOGGLE: [],
CMD_TORCH_ON: [],
CMD_TORCH_OFF: [],
CMD_TEST_OS: [],
Expand All @@ -49,6 +51,8 @@ def on_api_command(self, command, data):
self.plugin.activate_lights()
elif command == CMD_LIGHTS_OFF:
self.plugin.deactivate_lights()
elif command == CMD_LIGHTS_TOGGLE:
self.plugin.switch_lights(not self.plugin.lights_on)
elif command == CMD_TORCH_ON:
self.plugin.activate_torch()
elif command == CMD_TORCH_OFF:
Expand Down

0 comments on commit 4f247c4

Please sign in to comment.