Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

API Control

StefanCohen edited this page Oct 9, 2019 · 11 revisions

Everything that can be controlled by UI buttons on the enclosure tab can be controlled by a simple REST API.

You need to enable API under octoprint settings, it should be under features for the main octoprint settings.

Copy the api key, I'll reference it by from now on.

#List all Inputs.

Method: GET

http:///plugin/enclosure/inputs?apikey=

Response:

[ { "index_id": 1, "label": "Input 1" } ]

#List a specific input.

Method: GET

http:///plugin/enclosure/inputs/1?apikey=

Response:

{ "controlled_io": null, "filament_sensor_timeout": 120, "filament_sensor_enabled": true, "temp_sensor_address": "", "printer_action": "filament", "controlled_io_set_value": "low", "temp_sensor_type": "11", "temp_sensor_navbar": true, "temp_sensor_humidity": 19, "edge": "fall", "ds18b20_serial": "", "action_type": "output_control", "input_pull_resistor": "input_pull_up", "input_type": "temperature_sensor", "temp_sensor_temp": 33, "label": "Input 1", "index_id": 1, "use_fahrenheit": false, "gpio_pin": "4" }

#List all outputs

Method: GET

http:///plugin/enclosure/outputs?apikey=

[ { "index_id": 1, "label": "Ouput 1" } ]

#List a specific output

Method: GET

http:///plugin/enclosure/outputs/1?apikey=

{ "linked_temp_sensor": "", "ledstrip_gpio_dat": "", "startup_time": 0, "temp_ctr_deadband": 0, "neopixel_brightness": 255, "new_duty_cycle": "", "gpio_pin": 0, "default_duty_cycle": 0, "neopixel_color": "rgb(0,0,0)", "hide_btn_ui": false, "temp_ctr_set_value": 0, "temp_ctr_default_value": 0, "default_neopixel_color": "", "controlled_io_set_value": "Low", "auto_shutdown": false, "shell_script": "", "label": "Ouput 1", "default_ledstrip_color": "", "duty_a": 0, "toggle_timer_off": 0, "alarm_set_temp": 0, "ledstrip_gpio_clk": "", "auto_startup": false, "controlled_io": 0, "shutdown_time": 0, "temp_ctr_type": "heater", "gcode": "M117 Test", "shutdown_on_failed": false, "temperature_b": 0, "ledstrip_color": "rgb(0,0,0)", "temperature_a": 0, "neopixel_count": 0, "duty_cycle": 0, "toggle_timer_on": 0, "show_on_navbar": false, "duty_b": 0, "toggle_timer": false, "pwm_status": 50, "gpio_status": false, "pwm_frequency": 50, "new_ledstrip_color": "", "startup_with_server": true, "active_low": true, "temp_ctr_max_temp": 0, "pwm_temperature_linked": false, "temp_ctr_new_set_value": "", "output_type": "regular", "microcontroller_address": 0, "index_id": 1, "new_neopixel_color": "" }

#Enable/Disable Output:

http:///plugin/enclosure/outputs/1?apikey=

Method: PATCH Content-Type: application/json Body: { "status": boolean }

example: { "status": true }

#Enable/Disable Output auto-shutdown:

http:///plugin/enclosure/outputs/1/auto-shutdown?apikey=

Method: PATCH Content-Type: application/json Body: { "status": boolean }

example: { "status": true }

#Enable/Disable Output auto-shutdown:

http:///plugin/enclosure/outputs/1/auto-startup?apikey=

Method: PATCH Content-Type: application/json Body: { "status": boolean }

example: { "status": true }

The Older, now deprecated API:

Copy the api key, I'll reference it by {APIKEY} from now on.

You need configure the output from the enclosure setting to be able to use it from the API.

  • Regular GPIO
http://**{URL}**/plugin/enclosure/setIO?status=**{STATUS}**&index_id=**{OUTPUT_ID}**&apikey=**{APIKEY}**

OUTPUT_ID is the automatic generated number id from octoprint-enclosure setting

STATUS is can be true to turn it on and false to turn the output off

You can request all current gpio status with

http://**{URL}**/plugin/enclosure/getOutputStatus?apikey=**{APIKEY}**
  • Temperature control
http://**{URL}**/plugin/enclosure/setEnclosureTempHum?set_temperature=**{SET_TEMP}**&index_id=**{OUTPUT_ID}**&apikey=**{APIKEY}**

SET_TEMP is the set temperature for that temperature control item

  • GCODE
http://**{URL}**/plugin/enclosure/sendGcodeCommand?index_id=**{OUTPUT_ID}**&apikey=**{APIKEY}**
  • PWM
http://**{URL}**/plugin/enclosure/setPWM?new_duty_cycle=**{PWM_VALUE}**&index_id=**{OUTPUT_ID}**&apikey=**{APIKEY}**

PWM_VALUE should be between 0 and 100

  • Neopixel
http://**{URL}**/plugin/enclosure/setNeopixel?red=**{RED_VALUE}**&green=**{GREEN_VALUE}**&blue=**{BLUE_VALUE}**&index_id=**{OUTPUT_ID}**&apikey=**{APIKEY}**

RED_VALUE, GREEN_VALUE and BLUE_VALUE should be a value between 0 and 255

Clone this wiki locally