TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Turn on 3D printer, print, then turn it off

    Scheduled Pinned Locked Moved Raspberry Pi
    1 Posts 1 Posters 831 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR Offline
      Russ
      last edited by Russ

      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:

      c24702c1-cfa3-4427-9cf8-94970ca99625-image.png

      This article explains how to setup the Alexa routine.

      This video shows me printing something via TRIGGERcmd.

      Russell VanderMey

      1 Reply Last reply Reply Quote 0

      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
      • First post
        Last post