DIY Apple AirPrint/Play & Homekit on Raspberry Pi
Overview
Our HomePi was originally cobbled together to integrate older/non-complaint devices into the world of Apple AirPlay/Print. The little gizmo has evolved over time as devices change in/out around the house and now supports Apple HomeKit to integrate non-compliant 'smart' devices.
The HomePi has worked like a champ for years. This recipe is basically a retrace of my steps for future rebuilds, but may be useful to others.
Migrated to new site spring 2021 - original site/recipe available HERE (via Internet Archive)
Decommissioned in fall of 2023. ServerPi now provides Apple/Homekit services.
HomePi: Apple Air Print/Play & Homekit Services
Original: May 2014
Last Update: October 2023 - Retired!
Background & Capabilities
Many of the techno problems around our home tend to revolve around integrating older equipment with modern devices or attempting to deal with the deluge of new 'smart' devices, each with its own App or interface. Our 'vintage' stereo and network printer were prime examples of the old world - simply not iPhone/iPad compatible in terms of streaming music or printing.
On the other end of the spectrum, we seemed to be constantly fumbling with a variety of apps provided with our newfangled smart home (lights, switches, appliances, etc) - Waaay too complicated!
The Raspberry Pi was originally dropped onto our network to fill the Air Gap by emulating Apple AirPlay and AirPrint services and ultimately added HomeKit services so Siri could begin helping out around the house.
Evolution
HomePi V1 (2014): Raspberry Pi 1 Model B used to integrate an old network printer into the Apple AirPrint world (Cups).
HomePi V2 (2015): Added AirPlay services (Shairport-sync) services to allow iPads/iPhones to stream music to Bose Wave Radio.
HomePi V3 (2018): Homekit services (homebridge) added to pull together our 'smart' home. Integrates non-compliant smart devices into Apple Homekit world. V3 also involved simplified OS (DietPi) and RPi 3 Model B hardware.
Home Pi V4 (2020): V4 involved an OS (Buster) upgrade and more simplification. AirPrint services were dropped due to new network printer that no longer needed help.
HomePi V5 (2023): V5 rebuild/cleanup. Recipe updates here/there based on latest releases. No longer using Shairport or CUPS but left steps in recipe as options.
Retired in fall of 2023: DietPi recently added Homebridge to optimized software list. This was really all that was left on our HomePi. Migrated Homebridge to ServerPi and decommissioned this RPi to simplify our world ... twas a nice long run!
Level of Difficulty & Prep Time
A cheap, easy and fun little project - no programming required but Raspberry Pi/Linux knowledge will come in handy. 1-2 hours to get things installed and running.
MUCH easier than it used to be, thanks to DietPi ... original recipe to the right (pdf).
Just in case!
Hardware
Our current HomePi hardware profile:
Case: Official Raspberry Pi 3 Case*
MicroSD Card: Samsung 32GB MicroSD EVO Memory Card*
Power Supply: 2.5A Power Supply w/ On/Off button*
For Airplay
Audio Cable: 3.5mm Male to 2 RCA Male Stereo Audio Y Cable*
Sound Card: USB Audio Adapter (USB to to 3.5mm audio jack)*
*Note: Affiliate Links, I may get kickback from Amazon if you click/buy!
Software
Dietpi is now used for the HomePi foundation. It provides a lite version Raspbian and includes a library of optimized Pi software packages.
DietPi.com - Currently v7.0.2/Buster (Donate!)
Etcher.io - Much easier way to flash OS images to SD
AirPlay via Shairport-Sync option in DietPi Optimized Software
AirPrint via Cloudprint option in DietPi Optimized Software library
HomeKit - Smart Device integration via Homebridge Project
Step By Step
DietPi Install
Notes to self on OS Prep (DietPi IS RaspOS) and some handy optimized packages ...
Downloaded latest DietPi via https://dietpi.com/#download and followed along with latest Installation Guide
// Used DietPi_RPi-ARMv8-Bullseye.7z (~130 MiB Download) //Easiest to start DietPi install with Ethernet, keyboard & monitor then switch to ssh after first boot
Login (root/dietpi), wait for updates ... then ... Change passwords & Disable serial/UART (~5min)
Couple of configuration tweaks via Dietpi-Config utility (in menu). Minimally, set the following:
DietPi-Config/Language&Regional->Local=en.US.UTF-8 + Timezone + Keyboard[us]
// Season to taste, keyboard and country! //DietPi-Config/Network Adapters->WiFi
// I setup WiFi @ this point and disconnect Ethernet on next boot - Remember to Apply/Restart Network //DietPi-Config/Security Options->Change Hostname
// Changing Hostname will force reboot //
Install Software via DietPi-Software utility->Browse or Search Optimized Software
// Homebridge is a manual install process, see below //Avahi-Daemon: hostname broadcast (mac, pc bonjour)
Optional: System Stats & Management->DietPi Dashboard (or RPi-Monitor)
Media Systems->Shairport Sync (IF you plan to provide AirPlay Services, see below)
Printing->CUPS: common Unix printing system (IF you plan to provide AirPlay services, see below)
Remember to scroll down to do the actual Installation: select Go >> Start installation for selected software
Final/Favorite tweaks 'n such via command line:
Install your favorite editor - I like joe:
apt-get install joeDisabled WiFi Power Management to be safe (not sure if this is still needed ... iwconfig may need to be installed)
iwconfig wlan0 power off
AirPrint (Cups)
Our old printer finally passed away, so HomePi no longer provides AirPrint services, but here's the original recipe updated for DietPi. I ran a quick test, looks to be good-to-go. Install/setup takes ~30 Mins.
Double check that avahi & CUPS were installed during DietPi Install steps above
// I think "dietpi-software list | grep =2 " will highlight installed software //Dietpi CUPS @ https://dietpi.com/docs/software/printing/#cups
Quick Start @ https://www.cups.org/doc/overview.html
Make sure CUPS and friends are running after the install
http://<homepiIP>:631
CUPS Config via CUPS web interface @ http://<your PI IP address>:631 (https in latest cups)
Log in to CUPS administration using DietPi root/<rootpw> credentials
Administration page: double check to ensure "Share Printers" and "Allow Remote Admin" are checked
Administration/Add Printer - "Discovered Network Printers" found our Dell M5200 & Brother Printers
Couple of tweaks:Set "Printer Description" to match your printer, it is presented in iPhone/Pad's 'Select Printer" dialog
I uses Openprinting.org ppd file to set up our printer - https://www.openprinting.org/printers
Remember to check the "Share this Printer" box
HowTo Use AirPrint to print from your iPhone, iPad, or iPod touch by Apple Support
AirPlay (Shairport-sync)
Shairport-sync can be fully installed via DietPi-Software utility. Project page @ https://github.com/mikebrady/shairport-sync
Our HomePi used a cheap USB soundcard (like this*), make sure it is plugged in before you start
DietPi-Config/Audio Options->Enable Audio, then set Soundcard=usb-dac
// This will also install ALSA: Advanced Linux Sound Architecture //Install Shairport-sync via DietPi-Software utility: Software Optimized->Media Systems->
[*] 37 Shairport Sync: AirPlay audio player with multiroom sync
// Remember to "Install/Start Installation" - also - I stuck with AirPlay 1 version here //Set Mic and Headphone volumes via alsamixer utility.
I set Headphone (output) to just under redline and Mic to ZEROOne quick edit to config file @ /usr/local/etc/shairport-sync.conf:
Change the device "name" to something descriptive or it let it default to hostname - 'name' shows on ipad/iphone/itunes as speaker/destination.
Have also set interpolation to "soxr" ... optional, read comments/notes in .conf file
general =
{
name = "Family Room Bose";
interpolation = "soxr";
};
Apples Support's article on using AirPlay - How to AirPlay Audio
HomeKit (HomeBridge)
**** 2024 update: HomeBridge was added to the DietPi software library sometime in 2023 (I think!). No need for the manual install below ... or HomePi server (for me!) - Homekit services were added to our ServerPi. Dietpi HomeBridge info is @ https://dietpi.com/docs/software/home_automation/#homebridge ****
This one will still take some time, count on an hour with minimal plugin playtime!
Homepage/info @ homebridge.io, github.com/homebridge/homebridge. Install Steps are dissected from *new* HomeBridge on Raspian Lite instructions.
One very important preliminary: Check for plugins for your smart devices before you go through all this install stuff - just to make sure you'll be able to control your device. Go to https://www.npmjs.com and search for "homebridge-<your dev>". For example "homebridge-wemo" or "homebridge-" to browse the library.
No need to sudo if you are logged in as root on DietPi
Via dietpi-software utility: Install a few prerequisites from Development & Programming Category
[*] 9 Node.js: JavaScript runtime environment
[*] 17 Git: Clone and manage Git repositories locally
[*] 130 Python 3: Runtime system, pip package installer and development headersAdd homebridge repository
Repository gpg key:
curl -sSfL https://repo.homebridge.io/KEY.gpg | sudo gpg --dearmor | sudo tee /usr/share/keyrings/homebridge.gpg > /dev/nullAdd Repository to system sources:
echo "deb [signed-by=/usr/share/keyrings/homebridge.gpg] https://repo.homebridge.io stable main" | sudo tee /etc/apt/sources.list.d/homebridge.list > /dev/null
Install Homebridge and Homebridge Config UI X
Homebridge (which now seems to also install user interface (Config UI)
apt-get update
apt-get install homebridgeLog into Homebridge Config UI X (This is NICE!) - Default uc/pw = admin/admin - and follow "GET STARTED"
http://<ip address of your server>:8581
Install Plugins based on your IoT world ... The following is a blow-by-blow of adding Nest Plugin - mostly for my sake!
Steps dissected from https://www.npmjs.com/package/homebridge-config-ui-xLogin to UI X via http://<homepi>:858, clink on "Plugins" in the menu bar
Search for plugin's by name/keyword. There may be multiple plugins to choose from, you'll need to research (check project and readme).
Alternatively, search directly via npmjs.com using "homebridge-" as a prefix. You can sort/filter based on popularity, quality, maintenance, etc.INSTALL link on UI X page will add the plugin - homebridge-nest (Nest v4.6.9 plug-in using native Nest API) has worked well). Plugin's routinely run through a setup/configuration dialog - Nest doc @ https://github.com/chrisjshull/homebridge-nest.
Set up IOS phone via https://support.apple.com/en-us/HT204893.
PIN/Scan code is on main page of Config UI X. You can also dig it out of systemd journal via journalctl -u homebridgeDebugging: Troubleshooting Guide @ https://github.com/nfarina/homebridge/wiki/Basic-Trouble-Shooting
Apple Home info @ https://www.apple.com/ios/home/
Touch-ups & Tweaks
Spring 2023 Update Notes
Cleaned up the recipe but ended up not upgrading to fresh Bullseye rebuild. Decided to hold off because of an issue with Backup/Restore @ https://github.com/homebridge/homebridge/issues/3346. Will revisit when I have time.
A couple of plugin updates
Updated Node.js by hand - v16.19.1 to v18.16.0. Pretty simple/painless via Homebridge ... should be automagically managed by Dietpi in new recipe(?!).
More info @ https://github.com/homebridge/homebridge/wiki/How-To-Update-Node.js.
Check version via: node -v
Update via: [sudo] hb-service update-nodeHomebridge-Hue: v0.13.49 to v0.13.59
Homebridge-Wemo: v5.0.5 to v6.0.2
homebridge-smartthings-ik: v1.5.0 to v1.5.8
Winter 2022 Update Notes
Some cleanup/updates: A couple of new "Smart" things to incorporate into the home and some forced plugin updates. Also removed the soundcard and cable to Bose - Airplay services no longer needed or used - HomePod sits right on top of Bose radio and sounds just as good! ... notes/log
Failed attempted an update to Buster, ended up with some clumsy network issues during install, decided to simply update for now.
DietPi Tweaks/Updates
dietpi-update v8.13.2->v8.14.2 ...
also did a - apt upgrade Y
dietpi-software - couple of changes
Removed shairport-sync, no longer need to offer Airplay services.
Added DietPi-Dashboard (backend only) - HomePi is now monitored via ServerPi on our network
Removed RPi-Monitor - replaced by Dashboard
dietpi-config
Disabled Audio - no longer needed
Homebridge
Update to v1.6.0 via UX
Plugins:
Replaced Homebridge Smarthings with Smarthings Plugin a while ago. It works and ia much simpler but some noticeable delays (slowly improving)
Updated new plugin to v1.5.0 - webhooks coming soon!
Uninstalled old plugin
Enough for now ... will do a rebuild using Bullseye in the spring, I think that should simplify this gizmo even more
Spring 2022 Update Notes
Spring cleaning during the winter ... some leftover HomePi updates. Should be good for a long while!
DietPi update from 7.5.2 to 8.1.2 ... no issues. Just let dietpi-update do it's thing!
Homebridge World
Homebridge update v1.3.6 to 1.4.0 ... no issues
Homebridge Plugins
HomebridgeUi update from v4.41.2 to 4.42
Homebridge Deebotecovacs update from v1.4.6 to 1.4.7 ... hmmm some odd chatter during update
Homebridge-hue update from v0.13.22 to v013.36
plugin recommends running on Node.js v16.13.2 or later ... Easy enough:
From Homebridge "How to Update Node.js" article, did one of these: hb-service update-node
Homebridge Nest update from v4.6.3 to 4.6.4
Homebridge Platform Wemo v3.3.1 - Replace with Homebridge-wemo v4.7.0
Platform Wemo was deprecated/replaced quite a while ago but w/out auto migration. Just hadn't taken time to deal w/ ramifications of automations and such - some old/original smart-stuff here
Step-by-step based on info @ https://www.npmjs.com/package/homebridge-platform-wemo
Backup Homebridge (... Backup/Restore)
Saved a copy of json from HB Config editor (not much there)
Disabled current Wemo-Platform Plugin and restarted HB
Uninstalled Wemo-Platform Plugin
Installed homebridge-wemo Plugin and accepted config as presented (json looked just like old)
Restarted HB
Had to move Wemo stuff to correct room assignments and re-setup Automations ... not too bad
Homebridge Bravia Tvos - v5.0.1 to v5.0.8
Homebridge Nest - v4.5.4 to v4.6.4
Homebridge Smartthings - v2.3.8
Fall 2021 Update Notes
Loooong time since last update
DietPi update from 7.0.x to 7.5.2 ... with one little bump in the road ...
Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable'
To fix, did one of these:
apt-get update --allow-releaseinfo-change
... Then let dietpi-update do it's thing. All else seemed wellHomebridge Update
Homebridge now v1.3.4
Some of the Homebridge Plugins were complaining about needing Node.js v14.17.2 or later ...
From Homebridge "How to Update Node.js" article, did one of these:
hb-service update-nodeHomebridge Plugins
HomebridgeUi - no issues going to v4.41.2
Homebridge-hue - no issues during update, now v0.13.22
Homebridge-platform-wemo - project apparently moved to homebridge-wemo, but will change some other time. No update issues, now v3.3.1
Homebridge Bravia Tvos (not used) - v5.0.1
Homebridge Nest - v4.5.4
Homebridge Smartthings - v2.3.8