Printing with CUPS

Interesting… hadn’t seen this before. Will look into it. Thanks!

Sorry, I missed you message.

My trial-code can be found here: https://github.com/bouwew/hassio-addons
You can see I commented out most of the code inside the dockerfile.
This remaining code installs cups in a docker, at least, it worked for me at the time.
But you still need to add the configuration. Have a look at https://addons.community
There are many dockerfiles and configuration setup where you can get inspiration from.
Good luck!

People pushing back because CUPS isn’t considered a home automation-related component on another thread is a tiny bit ridiculous. Here’s my personal setup where HA is actually automating my printer using CUPS.

Since I’ve never attempted building any sort of docker container I installed CUPS and SANE on my second RPi. With CUPs all set up I was able to print remotely from my laptop. I had some issues through my phone though as sometimes it wouldn’t show up or it would quickly appear and disappear not being able to select it in time. But was happy for the time being as I mostly printer through the laptop anyway.

Then it got me thinking that there must be a CUPS equivalent for scanners so I found out about SANE, since I was having the same issue with the scanner that I had to get it out, power it up, connect it to the laptop and then finally scan. I was able to get SANE to work through the command line but couldn’t set up the scanner’s own buttons to work and using SANE through windows was also not looking promising.

Idea #1: I have HA so let’s try implementing something through it. I can’t get the physical buttons to work on the scanner so I’ll make button on HA that will trigger the scanner. So I ended up setting up simple switches that turning them on would execute commands which involved connecting to second Rpi through SSH and firing some Bash files.

I ended up with three buttons

  • scanning and saving to a network drive
  • scanning and sending it to my email
  • scanning and printing it (since I had CUPs already set up)

image

Wasn’t the greatest implementation but it seemed to work so I was happy with it.

Idea#2: The first idea worked good enough for me but I wanted something that others in the house could easily use. Having to go to HA find the buttons and click on the right one for someone like my parents isn’t the easiest of things to teach.

Here comes one of the best platforms ever made - ESPHOME! I anyway wanted a nodemcu running ESPHOME in the office to implement a motion sensor to automate the lights so I simply attached some buttons as well and added the automations on the esphome yaml itself and they just fire immediately.

So now you can completely bypass the HA interface, you just press a button next to the printer/scanner and works like a charm. There’s a button for each one of us in the house, which scans a document and sends it to the person’s email. And then a common button that scans and sends it to the printer if someone wants to copy a document.

I don’t see anyone in this thread doing that.

Yeah not on this thread. But here

You could argue the same for Pi-Hole. And yet it is an add-on.
That is the nice thing of using a Docker: you can integrate anything you want into HA that way (as long as you are capable of creating a working Docker :slight_smile: )

1 Like

One day I might just give it a go. First I need to get my hands on a server :slight_smile:

Even without “unrelated” add-ons, that argument is wrong anyway. If someone wants to automatically print a document when a new one becomes available or one is updated or just on a regular interval then that’s automation.

I’d be interested in a CUPS/SANE addon, mostly just to be able to trigger the scanner from a cheap Chromebook that otherwise can’t access the printer/scanner.

Ok for me!

I could get cups up and running in docker, but I struggled to get avahi and air print going to support airprint. I have it working fine installing directly through terminal, but would love an option for a cups-avahi-airprint addon. I found a few containers that seemed to cover it all, but I didn’t want to hand over full host access to get them going.

i configured cup using Portainer on my pi 4 with Hassos… The problem now is that using Hassos 4.20 it works fine, but upgrading to Hassos 5.9 the server still works, but no printer is shown on the net. Which is the problem? What I have to do to share the printer added in cups docker? please help me, thanks.

Still no one created CUPS add-on for HA? :slight_smile:

I found this, not tried yet
https://github.com/ncarr/addon-repository

I just installed from ncarr’s repo and it works for me with one issue: “502 Bad Gateway” when accessing the Web UI with HTTPS access (default).
See the discussion over here at GitHub:

After disabling SSL in the configuration, it works both in the integration and with “http://homeassistant.local:631”. The latter is a bit unsafe, though.

In my case I suspect this happens due to the already running nginx add-on.
BUT: Some printing services (e.g. newer Android) require SSL, so a solution to this issue would be desirable.
Ironically, though, Windows 10 still can connect via HTTP only as it seems (source).

How safe is it to add such custom add-on? I trust the original cups.

original cups? how do you run it in HA?

I run it on a different pi than hass. But is more economical to put them both on the same pi.

Well there is a question with a lot of fish hooks!

Easy answer, it is all open source so either trust that any errors are obvious or see for yourself :slight_smile:

Not so easy answer - this addon depends on a large train of trust, you need to trust the following:

  • Debian (extremely safe, there are a lot of eyes on debian)

  • The HA debian addon images (I don’t know what they do to them, but probably very safe, the devs here know their stuff and many official and community addons are built on those images).

  • On top of the base images there are a number of packages installed from debian repos, again all probably extremely safe.

  • Then we have the authors work on top of that. It is easy to see on his github. Nothing leaps out as bad, but without knowing all the possible things that could go wrong, who knows? Looks pretty innocuous though.

Frankly it looks as trustworthy as any other addon, but no guarantees about anything!

2 Likes

Sound answer, thanks!

Ive installed the addon. I can print a test page.
Airprint doesn’t work though, any ideas?