Hi!
I wrote a guide to how I set up the PSU control plugin in conjunction with Ikea Trådfri on Reddit and thought that I might as well post it here too:
Inspired by this post by u/tollsjo I wanted to try my hand at creating a setup where I could control the power of my Ender 3 without any additional hardware, given that I already have an Ikea Trådfri Wireless Control Outlet and an Ikea Trådfri Gateway.
The idea basically being that I could get Octoprint to turn off the printer when a print is done, and in my case also turn off the lights and the ABL sensor.
You'll need
- Octoprint running on a device that can run node (which should be basically any device that's capable of running octoprint?) and access to a console on that device (e.g. ssh-access to a raspberry pi)
- An Ikea Trådfri Gateway (take note of the 16 character alphanumerical key on the back, you'll need that later)
- An Ikea Trådfri Wireless Control Outlet
My Hardware Setup
- Octoprint running through the default Octopi image on a Raspberry Pi 2b
- Ender 3, Tru-Lev and IKEA Jansjö lamp all connected to an Ikea Trådfri Wireless Control Outlet, conveniently named "Ender" in the Trådfri app
Software setup
- Connect to your device in your preferred manner and open a console, in my case SSH into my rPi using the terminal.
- Install git
sudo apt-get update
sudo apt-get install git
-
Navigate to folder of choice (I chose to stay in the home folder of the default pi user)
-
Clone the tradfri-cli repository
git clone https://github.com/wschenk/tradfri-cli.git
- Install the tradfri-cli repository by navigating into it and running node install
cd tradfri-cli
npm install
- Test that your setup has run correctly (and check that the Trådfri devices you want to control are listed)
IKEASECURITY=PUTYOURSECURITYCODEHERE node devices.js
- Test that you are able to successfully control the devices (in this example, turning on an outlet called Ender)
IKEASECURITY=PUTYOURSECURITYCODEHERE node device_changer.js "Ender" --on
-
In Octoprint, install the PSU control plugin as you do with any other plugin
-
Configure the PSU control plugin to use the Tradfri-cli script using the built in settings.
a) Set "Switching method" to "System Command"
b) Set "On System Command" to
cd /home/pi/tradfri-cli/ && IKEASECURITY=PUTYOURSECURITYCODEHERE node device_changer.js "Ender" --on
c) Set "On System Command" to
cd /home/pi/tradfri-cli/ && IKEASECURITY=PUTYOURSECURITYCODEHERE node device_changer.js "Ender" --off
d) Set "Sensing method" to internal
e) Activate "Automatically turn PSU OFF when idle"
(of course, for b and c you'll need to change your script location to match where you installed the script, add your security code and change the name of the device to match yours)
To test that everything is working fine you can test the PSU control plugin by pressing the newly added lightning-button in the menu bar of your Octoprint dashboard.
Happy printing!