A simple plugin that allows for the toggling of a GPIO pin on the Raspberry Pi. The user can toggle the pin through a button in the navigation bar, an external button, OctoPrint events and through custom GCODE commands. Printer events also allow the pin to be toggled on then off after a period of time.
Install via the bundled Plugin Manager or manually using this URL:
https://github.com/thomst08/OctoLight/archive/master.zip
Currently, you can configure settings:
Light PIN
: The pin on the Raspberry Pi that the button controls.
BOARD
mode, else it will use BCM
mode. If the GPIO's are in BCM mode, you will need to use the GPIO number instead of the pin number, for example, pin 13 is GPIO 27, so the pin should be set to 27.
Inverted output
: If true, the output will be inverted.
Treat light pin as a button
: If true, the output will be treated as a button press.
Button Press delay (ms)
: This sets a time out for how long a button press is, this is only used if Light is a button
is enabled.
Delay Light Off (mins)
: This sets a time out for when the light will automatically turn its self-off in an event.
Enable External button
: This allows the use of an external button to change the state of the light.
Button PIN
: The pin on the Raspberry Pi used to detect a button press.
BOARD
mode, else it will use BCM
mode. If the GPIO's are in BCM mode, you will need to use the GPIO number instead of the pin number, for example, pin 15 is GPIO 22, so the pin should be set to 22.Button pin is connected to v5
: This sets the button pin to detect when the pin receives a current
Setup Printer and OctoPrint Events
: This allows you to select what you would like the light to do on a printer event.
Enable Custom GCODE Detection
: This must be enabled for GCODE to be read and toggle the light.
Setup Custom GCODE
: This allows you to select what you would like the light to do when a set GCODE command is sent to the printer.
Note: As of version 1.0.1, the API has been updated to be more in line with a RESTFUL standard, instead of functions being changed with a GET
request, the new setup requires a POST
request and the command to be sent in the body. To keep backwards compatibility with previous API calls, the previous GET
commands can still be used, however, it is recommended to update as these commands will be removed around the end of 2024. Please reach out if this is an issue or if you need help. Please have a look at the new API calls below to update.
Base API URL: http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
This API returns light state in JSON for both GET
and POST
requests: {state: true}
GET
calls will require a API key with the "STATUS" permission. Without this, you will receive a 403 error. POST
calls will require a API key with the "CONTROL" permission. Without this, you will receive a 403 error.{ "delay": VALUE }
can be added to the body to override the default delay time.curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X GET http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "toggle"}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "turnOn"}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "turnOff"}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "delayOff"}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "delayOff", "delay": 3}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
curl -H "Content-Type: application/json" -H "X-Api-Key: YOUR_OCTOPRINT_API_KEY" -X POST -d '{"command": "delayOffStop"}' http://YOUR_OCTOPRINT_SERVER/api/plugin/octolight
Thank you goes out to the following people: