Errata‎ > ‎RaspberryPi‎ > ‎

HomePiV4: Apple AirPrint/Play/Homekit Services on a Raspberry Pi

Completed late September 2020
Last Update:  19 November 2020.  MUCH Easier!

Here's the latest step-by-step rebuild of our HomePi server - AirPlay and Homekit integration for non-apple compliant devices around our home. Basically notes-to-self, but may be useful to others. Feel free to drop me a line with suggestions or comments.

Background

Our HomePi has served as an integrator of non-compliant devices into our Apple iPhone/iPad/Mac world for quite a few years - originally filling the 'Air-Gap' to allow non-apple devices to participate in AirPlay/Print world. HomePi services have evolved over the years as devices were added/upgraded around the house.  V1 providing AirPrint capabilities for an old printer then adding AirPlay capabilities in V2 for our favorite Bose radio and finally V3 integrate non-compliant smart devices into the Apple Homekit world. See original DIY Apple AirPlay/Print HowTo for more Backgrounder.  V4 is simply an update/simplification minus AirPrint services because they were no longer needed.

Hardware

No change for V4 other than a fresh MicroSD card.

Software

No major changes for V4.  AirPrint services were no longer necessary (new printer) so DietPi Google Cloud Print is no longer installed.

DietPi Install Notes

Notes to self on OS Prep (DietPi IS Raspbian) and some optimized packages
  • Download latest DietPi and Etcher.  Follow DietPi Quickstart Guide
    // used DietPi_RPi-ARMv6-Stretch.7z (~90MB Download) //
  • Easiest to start DietPi install with Ethernet, keyboard & monitor then switch to ssh after first boot
  • Automatically resizes partitions, forces password changes and updates itself (~5min)
  • Config tweaks via SSH and DietPi-config utility.  Minimally, set the following:
    • DietPi-Config/Audio Options->Soundcard=usb-dac
      // For shairport-sync w/ usb sound //
    • 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 Net // 
    • DietPi-Config/Security->Change Hostname
      // Changing Hostname will force reboot //
  • Install Software via SSH and DietPi-Software utility
    • Software Optimized - Check the following
      • Media Systems->Shairport Sync (for AirPlay)
      • System Stats->RPi-Monitor (nice web-based monitor)
      • Printing->CloudPrint (aka cups for AirPrint)
      • Homebridge is still a manual install process, see below
    • Remember to scroll down to do actual Install - select Go >> Start installation for selected software 
  • Final/Favorite tweaks 'n such via command line:
    • Install favorite editor if you don't like nano.  I like joe:  apt-get install joe
    • Disabled WiFi Power Management to be safe
      $ iwconfig wlan0 power off

AirPlay (Shairport-sync)

Shairport-sync is also fully installed via DietPi-Software utility.  Project page @ https://github.com/mikebrady/shairport-sync
  • One 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.
    general =
    {
      name = "Family Room Bose";
      interpolation = "soxr";
    };

  • Apples Support's article on using Apirplay - How to AirPlay Audio

HomeKit (HomeBridge)

HomeBridge is still not part of DietPi software library ... manual install required, but it's a LOT easier than it used to be!  This will still take some time, count on an hour with minimal plugin playtime!  Homepage info @ https://github.com/homebridge/homebridge and Raspberry Pi specifics @ https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Raspbian
  • One preliminary - check for plugins for your smart devices before you go through install - 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.
  • Note - no need for sudo if you are logged in as DietPi root
  • Install Steps are dissected from *new* HomeBridge on Raspian Lite instructions
    1. Install Node.js
      # setup repo
      curl -sL https://deb.nodesource.com/setup_12.x
      | sudo bash -
      # install Node.js
      sudo apt-get install -y nodejs gcc g++ make python
      # test node is working
      node -v
      # upgrade npm (version 6.13.4 has issues with git dependencies)
      sudo npm install -g npm
    2. Install Homebridge and Homebridge Config UI X
      sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x
      # To setup Homebridge as a service that will start on boot use hb-service command.
      sudo hb-service install --user homebridge
    3. Log into Homebridge Config UI X (This is NICE!) - Default uc/pw = admin/admin
      http://<ip address of your server>:8581
    4. Couple of name changes in Configuration Reference Section of guide
      Note: Service management is now via sudo hb-service restart/stop/start/logs instead of systemctl 
  • Config using Config UI X installed above. 
    The following is a blow-by-blow of our Smartthings and Nest upgrade - mostly for my sake!
    Steps dissected from 
    https://www.npmjs.com/package/homebridge-config-ui-x
    1. Log in via http://homepi:8581
    2. Smartthings:  Step by steps below MAY still need cleanup ... MUCH has changed since I installed original (pdlove) HomeBridge SmartThings!
      Followed https://techtechandmoretech.com/guides/smartthings-homebridge/ 
    3. Nest - Installed via Config UI X
      • homebridge-nest v4.4.9 (Nest plug-in for Homebridge using native Nest API)
        Doc @ https://github.com/chrisjshull/homebridge-nest
      • I still use Nest Account - pretty simple:  Access Token from home.nest.com/session
        (I'll update to Google account when forced to - this step is more complicated)
  • Set up IOS phone via https://support.apple.com/en-us/HT204893
    • if you forgot your pin/scan code dig it out of systemd journal
      sudo journalctl -u homebridge
  • Debugging:  Troubleshooting Guide @ https://github.com/nfarina/homebridge/wiki/Basic-Trouble-Shooting
    • Running in terminal window is very helpful 
    • See Also:  Common Issues section in the README

  • Apple Home info @ https://www.apple.com/ios/home/