Repository: OctoPrint

An addon to run OctoPrint on the same device as Home Assistant.

Installation

The repository is available at: fredrikbaberg/ha-3dprinter-addons: 3DPrinter-related add-ons for Home Assistant. (github.com), follow the instructions for Installing third-party add-ons to install.

Octoprint

Add-on to run OctoPrint, which is used for controlling 3D printers. Switching to Home Assistant OS meant I lost OctoPrint, so here is an add-on to solve that. Remember to read the notes below.

Notes

  • Image size varies depending on architecture, it is approximately 1 GB.
  • There is an issue with the armv7 version of the addon (used by e.g. Home Assistant OS 32-bit on Raspberry Pi 3) where the Python virtual environment is initially broken. A small verification is done on startup, with a repair taking place if needed. The repair itself takes time, please be patient for it to complete.

Tests

I’ve tested this add-on on a Raspberry Pi 3B+ running Home Assistant OS (64-bit), with a USB-connected Creality Ender 3 Pro 3D printer.

Versions

There have previously been multiple versions of the OctoPrint addon. As of 16th of November 2021 those are all marked as deprecated. The current version is called “3DPrinter-OctoPrint”.

5 Likes

Great work so far, I have succesfully printed and installed plugins. However it seems plugins are not sticking around with a reboot of hass.io or even a restart of the hass plugin. Again great work. If there is anything I can try let me know.

1 Like

Thank you for trying this, I hope the add-on is useful.
I thought I corrected the plugins disappearing after restart with version 0.2.1, could you check if that version has been installed?

I never checked for correct behavior between upgrades, which could be the issue if you installed and then updated. If you already have version 0.2.1, could I ask you to try to reset the octoprint settings through renaming the folder /config/octoprint to something else and then (re)start the add-on? You could also delete the folder, renaming is just so you have a copy of the previous files. On every startup I check if the folder exists, and if it doesn’t I copy a base config again.

My current (wild) guess is that the serverRestartCommand command was not updated. The above suggestion should give you a clean configuration, so if possible please try that. It may be enough to modify the command by hand to the following:

/data/OctoPrint/venv/bin/octoprint daemon restart --config /config/octoprint/config.yaml --basedir /config/octoprint >> /home/octoprint/log_octo.txt

I only have time to work on the code during some weekends, so unfortunately I’ll be unable to do changes to the code right now. When I get back home I’ll verify that the plugins are still installed on my Pi3, which I’ve restarted a few times.

1 Like

Now I’ve tried it myself, and can confirm that even the new version with a clean config does not keep the plugins, even though I was certain I fixed that.

I’m a bit short on time this weekend, but hopefully I’ll be able to resolve that the weekend after.

1 Like

There should be an update available now (0.2.2), if the latest changes went through as intended. I think I managed to solve the issue with plugins disappearing after restart, but I’ve only done a quick test, and that was with a local build, and not the image. Hopefully I’ll be able to test the image in a few hours.

What I didn’t check was the image size (should be roughly the same size, but I forgot to verify that), and now I am sure Bonjour support is not in place.

It is necessary to either remove the config/octoprint/config.yaml file, or change the server restart command by hand to:

serverRestartCommand: /home/octoprint/octoprint.sh

1 Like

Ok,
Got the update, just want to clarify the server restart command change, you are refering to the restart octoprint command within octoprints settings correct?
currently it is /data/OctoPrint/venv/bin/octoprint daemon restart --config /config/octoprint/config.yaml --basedir /config/octoprint >> /home/octoprint/log_octo.txt

thanks again for the add-on !!

1 Like

That is the line I meant, yes. You should also be able to change that directly from the OctoPrint UI, in case you don’t want to edit the file by hand. That command should ensure octoprint restarts, for instance when installing new plugins, if the restart button in the UI is used.

I hope the add-on works better now, and that the plugins stays after restarts.

Update: I discovered an error I’ve inserted in CuraEngine settings, which will be noticed if you try to slice directly from octoprint. I forgot to update the path to Cura, so that need to be adjusted if you want to use that feature. In OctoPrint Settings / CuraEngine there is an extra “/Cura”, the correct path should be:

/data/CuraEngine/build/CuraEngine

In order to fix that I’ll have to re-build everything, so for now I’ll wait with that until I’ve made more changes, so that I can test it properly.

I’ve considered letting the startup script update the path on each startup, but fortunately I didn’t do that. If I forget a change, as I did now, that would mean having to manually correct this on each boot. I might add that as an option in the future though, so that it can be forced.

1 Like

So far working good, everything seems to persist between restarts. Thanks again. So much better then running this all on multiple dev boards.

Hi, first of all thank you for the great work! After getting a new pi I’ve tried to install the addon but for some reason it uses amd64 instead of armhf. Where do you get the arch information? It could be a issue on my side but i couldn’t find a hass.io config…

1 Like

That is great! I’m pushing an update now (should be done in an hour or so), which should fix the Cura path error I made. Since it works for you, I don’t think you should update (should be the only thing, but safer to not update when it works as I didn’t add anything new).
Not having to set up one device for HASS.IO and one for OctoPrint was the exact reason I decided to do this.

1 Like

Hi k45t, thank you!
It seems strange it wants to use amd64 on Raspberry Pi, is it a Pi 3? Are you running the latest version of Hass.io?

The arch information should come from Hass.IO, I’ve followed the instructions for that part, and have tried the add-on on both my PC (amd64, but never connected the printer) and Pi 3 (armhf). The code is available on GitHub, I’ve just merged the latest changes into master.

If the latest version (0.2.3) doesn’t work, you could try a local build instead, and see if that solves the issue. Short instructions:

  • Look at the instructions on Developing an Add-on.

  • Instead of creating your own files, use the octoprint folder from my repository. You will need to remove the comma ending line 16, and all of line 17, in octoprint/config.json:

    “image”: “fredrikbaberg/octoprint-{arch}-image”

If the image-line is there, I believe it will try to download it, so to build locally you should remove that line.

If that doesn’t work, it may be possible to comment out the first line in the Dockerfile, uncomment line 2, and replace amd64 by armhf. I haven’t tried that though.

I’m installing the latest version of the add-on on my Pi3 now, 0.2.3, to make sure it still works.

1 Like

@fredrikbaberg thanks for making this, it’s exactly what I was looking for!

Is there anyway to configure it to /dev/ttyUSB2 instead of /dev/ttyUSB0? My printer shows us as that since I have other USB devices connected to my pi 3

Hi,
I think it should be possible, but you will have to do a local build instead. Unfortunately I’m a bit short on time for testing it right now. I haven’t figured out how to make it possible to change port without changing the Dockerfile (if someone has a suggestion, please tell me).

What you can try is:

  1. Put the folder octoprint, with its contents, from the repo, into the folder addons on your install. You should have e.g. addons/octoprint/Dockerfile
  2. Make the following changes to config.json in the octoprint folder:
    2.1. Change USB0 to USB2.
    2.2. Delete the line "image": "fredrikbaberg/octoprint-{arch}-image".
  3. Build the add-on through going to the add-on page in the Web UI.

It might be necessary to also change the settings of octoprint, but I’m unable to check that now. If it is, I believe that should be doable through the UI.

The following instructions should provide some guidance with where the files should be placed, and how to build: https://home-assistant.io/developers/hassio/addon_tutorial/

2 Likes

Thanks, it worked after I tweeked the Dockerfile, I had to change the top to the following to get it to build:

#FROM %BASE_IMAGE%
ARG BUILD_FROM
FROM $BUILD_FROM

1 Like

I’ve just made some changes, hopefully it still works as it should (I did a quick test on my setup). Updates are:

  • Updated to OctoPrint version 1.3.6
  • Uses BUILD_FROM (so should work with newer build system)
  • Solved issue with pybonjour install method reporting error for me during build.

USB* instead of USB0 did not work, so it’s still built only for USB0. For other ports, a local build is still needed.

2 Likes

Hi, firstly thank you for sharing this, so much better than needing 2 pi’s.

I need a little help tho, I cannot get the camera to work. I have had it working on an octoprint install before but it won’t load on this. I have tried it in all the USB ports and still nothing. I use Duckdns and https for hassio but octoprint only loads with http so not sure if that means anything? It does connect to the printer fine though.

Any help much appreciated

3 Likes

Hi,
I’ve currently disabled octoprint for my own printer (waiting for a new one), so unfortunately I can’t test it right now.
The addon requires specifying the ports to use beforehand, and the only one I’ve setup is for a USB-connected printer (USB0). In order to use a USB-camera, it might be enough to specify a second USB-port in the config.json file. If you feel somewhat confident in modifying and compiling by yourself, you could try that (https://github.com/fredrikbaberg/hassio-addons/blob/master/octoprint/config.json).

As for HTTPS, that may or may not also be fixed by modifying the same file. I’m a bit short on time now, but if you try it please tell me how it goes.

1 Like

I have just installed the OctoPrint add-on from your HASS.IO repository. I am brand new to Home Assistant, so I am a little confused. When I go to the Octoprint add-on for HASS.IO page, there is nothing in the Config section except for { }. I am unable to start the add-on. I honestly don’t know what to do next, or if I missed a step in the process. Any assistance would be appreciated.

1 Like

Hi,
Without seeing the log it’s difficult knowing why the addon doesn’t start. My guess is that the printer wasn’t found. Is it connected by USB? Do you have something else connected by USB, e.g. Conbee, Z-wave or 433MHz adapter? The assumed device ID is /dev/USB0, I haven’t figured out a way to specify it in the config (since it needs to be set beforehand).

I’ve currently paused developing, since the new printer I’m waiting for is delayed (and I’ve changed my setup to using a virtual machine).

1 Like

I don’t have any log entries, because the add-on is unable to start. I have the Raspberry Pi connected to my Monoprice Select Mini via USB. That is the only USB connected device on the Pi. Do I need to install anything else, such as the contents of the OctoPrint folder from your GitHub page? Please let me know, and thank you for replying to my first post so quickly.

1 Like