Skip to content

Commit 4f247c4

Browse files
committed
✨ Lights toggle API command
1 parent 98f7d2c commit 4f247c4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/documentation/rest-api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ See also the [SimpleApi docs](https://docs.octoprint.org/en/devel/plugins/mixins
9696
| :--- | :--- | :--- |
9797
| `lights_on` | None | Turn the LEDs on |
9898
| `lights_off` | None | Turn the LEDs off |
99+
| `lights_toggle` | None | Toggle the LED state |
99100
| `torch_on` | None | Turn the torch mode on |
100101
| `torch_off` | None | Turn the torch mode off. Only available if torch mode is configured as toggle. |
101102
| `test_os_config` | None | Begin an OS configuration test. Asynchronous, data is returned on the socket |

octoprint_ws281x_led_status/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Define API commands
1414
CMD_LIGHTS_ON = "lights_on"
1515
CMD_LIGHTS_OFF = "lights_off"
16+
CMD_LIGHTS_TOGGLE = "lights_toggle"
1617
CMD_TORCH_ON = "torch_on"
1718
CMD_TORCH_OFF = "torch_off"
1819
CMD_TEST_OS = "test_os_config"
@@ -33,6 +34,7 @@ def get_api_commands():
3334
return {
3435
CMD_LIGHTS_ON: [],
3536
CMD_LIGHTS_OFF: [],
37+
CMD_LIGHTS_TOGGLE: [],
3638
CMD_TORCH_ON: [],
3739
CMD_TORCH_OFF: [],
3840
CMD_TEST_OS: [],
@@ -49,6 +51,8 @@ def on_api_command(self, command, data):
4951
self.plugin.activate_lights()
5052
elif command == CMD_LIGHTS_OFF:
5153
self.plugin.deactivate_lights()
54+
elif command == CMD_LIGHTS_TOGGLE:
55+
self.plugin.switch_lights(not self.plugin.lights_on)
5256
elif command == CMD_TORCH_ON:
5357
self.plugin.activate_torch()
5458
elif command == CMD_TORCH_OFF:

0 commit comments

Comments
 (0)