Turn on 3D printer, print, then turn it off
-
This is the script I use to print something on my 3D printer via TRIGGERcmd. It turns the printer on, prints the object, then turns it off again.
#!/bin/bash -v tcmd --computer "octopi" --trigger "3d printer smart plug on" sleep 10 # wait for the printer to boot octoprint-cli connection connect octoprint-cli print select $1.gcode octoprint-cli print start # Loop until print job is finished while true; do # Retrieve job status job_state=$(octoprint-cli print status | head -n 1) # Check if the job is finished if [[ $job_state == "Printer Operational" ]]; then echo "Print job finished." break fi # Wait for the next check sleep 10 done tcmd --computer "octopi" --trigger "3d printer smart plug off"My /root/.TRIGGERcmdData/commands.json file looks like this:
[ {"trigger":"Reboot","command":"shutdown -r","ground":"background","voice":"reboot","allowParams": "false"}, {"trigger":"3d printer smart plug on","command":"echo","ground":"background","voice":"plug on","allowParams": "false"}, {"trigger":"3d printer smart plug off","command":"echo","ground":"background","voice":"plug off","allowParams": "false"}, {"trigger":"Start 3d print","command":"su - pi /home/pi/print.sh","ground":"background","voice":"print","allowParams": "true"}, {"trigger":"apt update","command":"apt-get -y update","ground":"background","voice":"update","allowParams": "false"} ]It uses two Alexa routines - one to turn my Wyze smart plug on, and one to turn it off (to turn the 3D printer on/off). This is a screenshot of the "off" routine:

This article explains how to setup the Alexa routine.
This video shows me printing something via TRIGGERcmd.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login