3d Printer Switch with Octoprint & SmartThings

My MakerGear M2 doesn't have a power switch, and it isn't convenient to turn off its power strip, so I connected it to an Iris Smart Plug with a little power switch on it. That solved the problem, and also let me turn the printer on and off with Alfred, but tempted me to intergrate with Octoprint. Octoprint has a plugin, System Command Editor, that lets you execute shell commands from Octoprint's Power menu. That makes the Octoprint part easy - now it's just a matter of controlling a SmartThings device from Linux.

That part turned out to be a bigger hassle than I anticipated. I ended up using David Janes' iotdb-smartthings. His tutorial is really excellent. I did have to make two small changes to smartthings.py, to get it working with my configuration.

On line 46, I changed "smartthings.json" to the absolute file path.

On line 81, I changed the url to https://graph-na02-useast1.api.smartthings.com. I believe whether or not you need to make this change depends on which smartthigns server you're using.

I also had to install pip, and then requests:

sudo apt-get install python-pip

sudo pip install requests

Then to turn the printer on, I use the command:

python path_to/smartthings.py --type switch --id MySwitchName --request switch=1

switch=0 turns the printer back off. At this point, all you need to do is load the commands into Octoprint's System Command Editor.

Content Type: