We finally have a working plugin. In the last blog that I wrote, I mentioned a problem that we had about not knowing where to call our plugin. I had narrowed it down to two possibilities (calling either upon user specification or automatically when the temperature to the bed or the hotend was changed). Our team chose the latter.

Our timer starts automatically when the target temperature of either the bed or the hotend is changed. The bed and hotend have different types of temperature; actual, and target. They are stored in a dictionary that we have access to. We can constantly update the temperature dictionary through a while loop as seen below in Figure 1. 

Figures 1 & 2: On after Startup

Upon server startup we do update and access this dictionary using two while loops, the first constantly updates the dictionary while it is empty. An empty dictionary would be caused by not having OctoPrint connected to your printer yet. This loop is basically telling our timer to wait until there is something in the dictionary.

The second while loop is used while the target temperatures of the bed and the hotend are both 0(off). If the temperature is off then we do not need our plugin. This loop is once again telling our timer to wait until we are needed.

Once the temperature is set, both of the while loops will be exited and then it will call our countdown() function (see Figure 2). This function grabs the user specified time and counts down. When it is finished, we call the shutdown() function (see Figure 2). This function checks to see if the printer is printing. If the printer is printing then we do nothing (because we do not want to mess up a print). However, if the printer is not printing then we shut down temperature to the bed and the hotend.

This is the season for excitement because our plugin works. We have learned so much about the world of OctoPrint, and although this is only a plugin, it feels like a milestone. We will be adding the finishing touches onto our plugin and submitting it to the other plugin mixins of OctoPrint.