3D Printer + smart plug + notifications integration

Hi everyone, here is my approach for the 3d printer automation:

Components used:

  • 3D printer (Anet A8)
  • Octoprint on a Raspberry 1B
  • Smart plug (I am using an Ubiquitus mPower Pro, but a Wemo or equivalent will work)
  • I use telegram for notifications, but you can use any notification flavor you prefer.

You will have to setup octoprint on your raspberry first, it connects via usb to the printer and manages it directly.
Octoprint official web
Then you have to add the configuration to your configuration yaml file as the octoprint documentation states:

 host: your octoprint ip
 api_key: your api key (you can get it on the octoprint options)

We want to add some sensors too:

  - platform: octoprint
    name: OctoPrint
      - Current State
      - Job Percentage


  - platform: octoprint
      - Printing
      - Printing Error

And here are the automation bits:
#3d printer automations

  - alias: Send me a notification when the print is above 50%
      platform: numeric_state
      entity_id: sensor.octoprint_job_percentage
      above: 50
     service: notify.Telegrambot
        message: "Print is at 50%" 
  - alias: Send me a notification when the print is finished
      platform: state
      entity_id: sensor.octoprint_current_state
      from: 'Printing'
      to: 'Operational'
     - service: notify.Telegrambot
        message: "Print has been finished"
     - service: homeassistant.turn_on
       entity_id: script.3dprint_off

As you can see, when the print has been finished, we start a script that works as follows:
> script:

        alias: ¨Turn off 3d printer after 2 minutes¨
          - delay:
              minutes: 2
          - service: switch.turn_off
              entity_id: switch.3dprinter

Hope that this helps out somebody, as it comes pretty handy. You can make some other related automations, that for example turns off the printer if it reports an error on the printing and notify you, etc…

Just let me know if you need any detail about it.

One detail: Octoprint component needs the 3dprinter to be on when home assistant is restarted or the component will fail


Nice! I have just picked up an Anet A8 3D Printer!

I was tempted to look into Octoprint to see if it’s worthwhile setting up. The RPI I have is a Rev1, and whilst supported cannot imagine it would be up to much.

What? No picture of your rig so we can all get jealous and stuff?? :wink:

Seriously though, nice job!

1 Like

I think RPI rev1 is sufficient for Octoprint if you don´t need the optional webcam and timelapse functions.

1 Like

Can I ask what settings you used to connect the printer in Octoprint? I didn’t have any luck with everything I tried. Latest version of octoprint running on a Raspberry pi model B.

Sure, you have to select 115200 as baudrate and in serial port you will have to choose /dev/ttyUSBx (if your octoprint is not detecting your usb you can try rebooting octoprint.

For the printer profile I have model Prusa,

Print bed size is

W 220
Y 220
H 240
Origin lower left

Axes X 6000
y 6000
z 200
e 300

Nozzle diameter 0,4 and number of extruders 1.

Hope that it helps you

Thanks for that. Will give it a go shortly but looks pretty similar to the settings I chose. I suppose the USB cable they supplied could be a dud. Are you using the stock firmware on the anet board?

Thanks for this. Saves me heaps of time.

1 Like

Supplied cable and stock firmware yes.

Ok thanks. Maybe something wrong somewhere in the mix. Will reflash the image and see if it makes a difference.

I did get it working fine with RPI Rev1. I just purchased a RPI Zero W (wireless version) to use that instead, but the Octopi image does not support it.

I am going to try manually building using the latest Raspbian Lite image.

What is a shame (and also have the same issue with the Zoneminder component) is that it requires Octopi to be accessible when HASS starts up. If you have it switched off (as I do when not using it) then restarting HASS causes it to freak out :frowning:

Wonder if there’s anything that can be done to solve this - I guess it’s also some limitation on the HASS back end too?

@mitsumaui – If you want a quick and easy setup for OctoPrint use OctoPi. That’s what I use for my RaspberryPi 2 connected to my Monoprice select mini.

Yep! I had Octopi running on a Pi Zero 1, and an RPI 1 without issue, but at the moment it does not support the Pi Zero W.

I have opened an ‘issue’ with OctPi on GitHub and they are looking to roll the latest Raspbian into their nightlies soon so should be able to test with that at some point. But hence the hand build for the moment!