I'm currently building a bed cooler (based on this design from thingiverse). My plan is to control the fans - which will be powered by a Shelly Plug S wifi switch - via the Webhooks plugin.
Now ideally the fans should stop running once the bed has reached a certain temperature close to room temperature. To do that I am looking for a way to execute the Webhook commands (but I'm not tied to that approach and open to other methods) once a pre-configured temperature threshold has been reached. However, I haven't been able to find a plugin or other method that does that.
I initially thought that the TemperatureFailsafe plugin could be of use but looking through it in more detail I'm afraid that it's only executed when the temperature goes above the threshold whereas I would need something that triggers when the temperature falls below the threshold.
Any ideas or suggestions would be much appreciated.
Nothing springs to mind as something that already exists, however this would be very easy to do if you wanted to get involved making your own plugin. There's a temperatures hook, and you could do this without too much. Now I know this is not what you want, and my definition of 'easy' is warped having created several plugins and worked on the core of OctoPrint but I still think it would be possible for someone fairly new to plugin development.
Hi Charlie, thanks for the quick reply and pointer towards the hooks. Looking at the octoprint.comm.protocol.temperatures.received hook and example code doing something quick and dirty (static commands, not UI for settings, etc.) does look fairly reasonable. Hopefully I'll find some time on one of the next weekends to give this a shot.
Thanks for the information, apparently there's even an OTA approach for Shelly devices which doesn't require me to disassemble the plug and do the reflash via cables. However, to get started I'll play around with time-based control of the fans and then look into writing a small plug-in myself. But it's always good to know that another solutions exists.
The Enclosure plugin has a "cooler" controller. However, at the moment, you can only assign a controller to a GPIO temperature sensor. The ability to associate a controller with the heatbed temperature sensor would be a perfectly reasonable (and trivial) feature request.
In the meantime, the Enclosure plugin invokes a unique Python script corresponding to each type of temperature sensor (BME280.py, tmp102.py, ...). You could hack one of the existing scripts to return the heatbed temperature.
Edit: Refer to my comment below regarding the octoprint.comm.protocol.temperatures.received hook.
At the moment, an Enclosure plugin controller is only capable of controlling GPIO "regular" outputs. Again, I think it would be a perfectly reasonable feature request to control other types of outputs.
I'm using Enclosure plugin heater and cooler controllers to control filament dryer heating elements and fans (simply for circulation). I'm also using Enclosure plugin heater and cooler controllers to control an enclosure heater (Lasko compact space heater) and an HEPA / activated-carbon air purifier with a three-speed fan. All of the heaters, heating elements and fans are controlled via Qwiic I2C relays. Again, the Enclosure plugin controllers don't support I2C outputs. I wrote a simple plugin that "maps" GPIO outputs to I2C outputs. Of course, this technique could be used to map GPIO outputs to anything.
The Enclosure plugin controllers support several practical startup and shutdown options,
Start with server - Choose if output should turn on automatically when octoprint starts
Auto Startup - Choose if output should turn on automatically when print starts
Auto Shutdown - Choose if output should turn off automatomatically when print finishes
I assume you'd like your fans to start automatically when the print finishes. I have a similar requirement with my air purifier. However, I'd prefer the air purifier simply run for a fixed (configured) period of time (e.g., 60 seconds to purge the air from the enclosure). Again, I think both options are perfectly reasonable feature requests.
Edit: @Dak0r has integrated the Enclosure plugin with the octoprint.comm.protocol.temperatures.received hook. The intension is for the Enclosure plugin to contribute the actual temperature and/or humidity of the configured sensors to the hook. However, with @Dak0r's integration, the hook makes the heatbed temperature available to the Enclosure plugin.
My somewhat convoluted (but functional) way of accomplishing this was with a relay, the "Gcode System Commands" plugin, and commands appended to the print job by my slicer.
I connected the fan to a relay, and the relay is controlled by gpio. I created scripts named "bedfan_on.sh" and "bedfan_off.sh" that use the gpio command line utility to toggle the relay on/off. (These are in the ~/.octoprint/scripts folder.)
In the Gcode System Commands plugin, I created two commands -- OCTO10 and OCTO11 -- that are linked to the above mentioned on/off scripts by the plug-in.
My ending G-code (appended by PrusaSlicer) includes these 3 lines:
OCTO10 ;turn on the bed cooling fan
M190 R50 ;set and wait for bed temp 50
OCTO11 ;turn off bed cooling fan
As an alternative to appending this with the slicer, I assume it would also work if placed into Octoprint's "After print job completes" script.
So as I have it cobbled together.... The print ends, the fan turns on, the bed cools down to 50, then the fan turns off. At that point, the Pushover plugin snaps a photo and sends it to my phone, and additional commands in the "After print job completes" script moves the bed forward with the completed and cooled print.
I also added Buttons to Octoprint's "control" tab so I'd have manual control of the cooling fan. I did that by adding the following to the config.yaml file:
- command: OCTO10
name: BedFan ON
- command: OCTO11
name: BedFan OFF
name: Bed Cooling Fan
I created Enclosure plugin feature requests to associate a cooler controller with the heatbed temperature sensor and to automatically start the controller once the print finishes and stop the controller once the target temperature or a maximum (configured) duration is reached.