plugin/enclosure/outputs API Only Returns Regular Outputs #403

Open
opened 2021-02-19 00:20:04 +00:00 by wickedbeernut · 0 comments
wickedbeernut commented 2021-02-19 00:20:04 +00:00 (Migrated from github.com)

Describe the bug
The plugin/enclosure/outputs API only returns outputs of type "regular".

    octoprint_enclosure/__init__.py

    @octoprint.plugin.BlueprintPlugin.route("/outputs", methods=["GET"])
    def get_outputs(self):
        outputs = []
        for rpi_output in self.rpi_outputs:
            if rpi_output['output_type'] == 'regular':
                index = self.to_int(rpi_output['index_id'])
                label = rpi_output['label']
                pin = self.to_int(rpi_output['gpio_pin'])          
                ActiveLow = rpi_output['active_low']
                val = PinState_Human(pin,ActiveLow)
                outputs.append(dict(index_id=index, label=label, GPIO_Pin=pin, State=val))
        return Response(json.dumps(outputs), mimetype='application/json')

To Reproduce
With only "non-regular" outputs,
http://octopi/plugin/enclosure/outputs
currently yields,
[]
Note that I can successfully access a specific regular output,
http://octopi/plugin/enclosure/outputs/1
which yields,
{"active_low": true, "alarm_set_temp": 0, "auto_shutdown": false, "auto_startup": false, "controlled_io": null, "controlled_io_set_value": "low", "default_duty_cycle": 0, "default_ledstrip_color": "", "default_neopixel_color": "", "duty_a": 0, "duty_b": 0, "duty_cycle": 0, "gcode": "", "gpio_pin": "12", "gpio_status": true, "hide_btn_ui": false, "index_id": 1, "label": "Dryer 1", "ledstrip_color": "rgb(0,0,0)", "ledstrip_gpio_clk": "", "ledstrip_gpio_dat": "", "linked_temp_sensor": 2, "microcontroller_address": 0, "neopixel_brightness": 255, "neopixel_color": "rgb(0,0,0)", "neopixel_count": 0, "new_duty_cycle": "", "new_ledstrip_color": "", "new_neopixel_color": "", "output_type": "temp_hum_control", "pwm_frequency": 50, "pwm_status": 50, "pwm_temperature_linked": false, "shell_script": "", "show_on_navbar": true, "shutdown_on_failed": false, "shutdown_time": 0, "startup_time": 0, "startup_with_server": false, "temp_ctr_deadband": 0, "temp_ctr_default_value": 0, "temp_ctr_max_temp": "30", "temp_ctr_new_set_value": "", "temp_ctr_set_value": 0, "temp_ctr_type": "heater", "temperature_a": 0, "temperature_b": 0, "toggle_timer": false, "toggle_timer_off": 0, "toggle_timer_on": 0, "current_value": false}
Expected behavior
After removing the check for output_type = "regular"
http://octopi/plugin/enclosure/outputs
yields,
[{"index_id": 1, "label": "Dryer 1", "GPIO_Pin": 12, "State": " OFF "}]
Additional context
I am attempting to programmatically identify all of the Temperature / Humidity Control outputs and the corresponding temperature sensor (linked_temp_sensor) and maximum temperature (temp_ctr_max_temp). Using the linked_temp_sensor, I can access the corresponding actual temperature and humidity using,
http://octopi/plugin/enclosure/inputs/2
allowing me to display the entire state of the "enclosures" (which may include one or more filament dryers) including target and actual temperature and humidity,
image

**Describe the bug** The plugin/enclosure/outputs API only returns outputs of type "regular". ``` octoprint_enclosure/__init__.py @octoprint.plugin.BlueprintPlugin.route("/outputs", methods=["GET"]) def get_outputs(self): outputs = [] for rpi_output in self.rpi_outputs: if rpi_output['output_type'] == 'regular': index = self.to_int(rpi_output['index_id']) label = rpi_output['label'] pin = self.to_int(rpi_output['gpio_pin']) ActiveLow = rpi_output['active_low'] val = PinState_Human(pin,ActiveLow) outputs.append(dict(index_id=index, label=label, GPIO_Pin=pin, State=val)) return Response(json.dumps(outputs), mimetype='application/json') ``` **To Reproduce** With only "non-regular" outputs, ` http://octopi/plugin/enclosure/outputs ` currently yields, ` [] ` Note that I can successfully access a specific regular output, `http://octopi/plugin/enclosure/outputs/1 ` which yields, `{"active_low": true, "alarm_set_temp": 0, "auto_shutdown": false, "auto_startup": false, "controlled_io": null, "controlled_io_set_value": "low", "default_duty_cycle": 0, "default_ledstrip_color": "", "default_neopixel_color": "", "duty_a": 0, "duty_b": 0, "duty_cycle": 0, "gcode": "", "gpio_pin": "12", "gpio_status": true, "hide_btn_ui": false, "index_id": 1, "label": "Dryer 1", "ledstrip_color": "rgb(0,0,0)", "ledstrip_gpio_clk": "", "ledstrip_gpio_dat": "", "linked_temp_sensor": 2, "microcontroller_address": 0, "neopixel_brightness": 255, "neopixel_color": "rgb(0,0,0)", "neopixel_count": 0, "new_duty_cycle": "", "new_ledstrip_color": "", "new_neopixel_color": "", "output_type": "temp_hum_control", "pwm_frequency": 50, "pwm_status": 50, "pwm_temperature_linked": false, "shell_script": "", "show_on_navbar": true, "shutdown_on_failed": false, "shutdown_time": 0, "startup_time": 0, "startup_with_server": false, "temp_ctr_deadband": 0, "temp_ctr_default_value": 0, "temp_ctr_max_temp": "30", "temp_ctr_new_set_value": "", "temp_ctr_set_value": 0, "temp_ctr_type": "heater", "temperature_a": 0, "temperature_b": 0, "toggle_timer": false, "toggle_timer_off": 0, "toggle_timer_on": 0, "current_value": false}` **Expected behavior** After removing the check for output_type = "regular" ` http://octopi/plugin/enclosure/outputs ` yields, ` [{"index_id": 1, "label": "Dryer 1", "GPIO_Pin": 12, "State": " OFF "}] ` **Additional context** I am attempting to programmatically identify all of the Temperature / Humidity Control outputs and the corresponding temperature sensor (linked_temp_sensor) and maximum temperature (temp_ctr_max_temp). Using the linked_temp_sensor, I can access the corresponding actual temperature and humidity using, ` http://octopi/plugin/enclosure/inputs/2` allowing me to display the entire state of the "enclosures" (which may include one or more filament dryers) including target and actual temperature and humidity, ![image](https://user-images.githubusercontent.com/47407361/108438457-87e46b80-720c-11eb-9b53-b492ce695a09.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#403