Free Airplay Support for Sonos Network

Using airconnect, we can instantly convert your Sonos Network into airplay supported network — oh did I mention also that it is entirely free?

Motivation

I own one Sonos Play:1 speaker. It sounds great and I loved that it is one of the cheaper Sonos speakers that still sounded really good. Recently, I was considering getting a second speaker and learnt that the Sonos One supported Airplay. Also, I found out I could potentially convert my Sonos Network by adding a Sonos One onto my network. Most importantly, they had a new Sonos One SL, which was exactly the same but without the microphone.

Circling back, the downside then became the price. The Sonos One SL, was slightly more expensive than the Sonos Play:1 speaker and the only value it provided was adding AirPlay to the Sonos Network.

Fortunately, I chanced onto this open-source project “airconnect”. It allowed current Sonos network to get free airplay support. I tested and it works great. Let’s see how to set this up.

As an aside, this small setup project will also let you play with macOS LaunchAgents and Linux systemd. So, here we go.

Airconnect

So, before we start, here is the github page to Airconnect. To get this to work, it is really simple, we just download the respective binaries for the different operating system and run the application. The application then finds the Sonos device and connects to it.

So here’s what we need.

  1. Either a Linux, macOS, Windows machine (let’s call this the Airconnect machine)
  2. Airconnect machine must be connected to the same network.
  3. Potentially run Airconnect 24/7 or autostart when we turn on the Airconnect machine.

Setting up on macOS

Setting this up on a mac is relatively simple. Here’s what I did to keep everything clean and neat in my network.

You can choose to download only the binaries for macOS, but I chose to clone the entire repository instead.

Clone the repository into your ~/Applications/airconnect folder with the following command.

$ git clone https://github.com/philippe44/AirConnect.git ~/Applications/airconnect

Next, let’s create a symlink that would allow us to run the binaries. We are going to make sure the binary is first executeable and then create the symlink in the /usr/local/bin folder and link it to ~/Applications/airconnect/bin/airupnp-osx-multi .

Note: The version of binary are named accordingly to aircast or airupnp for which OS. For example, airupnp-osx-multi is for airupnp on macOS

$ chmod +x ~/Applications/airconnect/bin/airupnp-osx-multi$ ln -s ~/Applications/airconnect/bin/airupnp-osx-multi /usr/local/bin/airconnect

Now to test everything is working as expected, make sure you are connected to the same wifi as your Sonos device, then just run the airconnect command without any parameters. If it worked, you should be able to see the Airplay device from your volume tool bar. It should be titled as what you have titled it when you first setup your Sonos device.

$ airconnect
Image for post
Image for post
Volume tool bar showing the Sonos Device

Now that we know it works perfectly when we run it manually, let’s automate this with LaunchAgents in macOS.

To do this, first create a file in ~/Library/LaunchAgents name it anything you want, but for this example, we’ll name it net.airconnect.bridge.plist . The contents of the file is as follows, next we are also going to create a folder in /usr/local/etc/airconnect and create a airconnect.log this file will hold our log file. You can also choose not to provide a log file if you prefer.

<?xml version=”1.0" encoding=”UTF-8"?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version=”1.0">
<dict>
<key>Label</key>
<string>net.airconnect.bridge</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/airconnect</string>
<string>-Z</string>
<string>-f</string>
<string>/usr/local/etc/airconnect/airconnect.log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

Very quickly, here is what the script is doing. It’s going to run the following airconnect command with the parameters flags -Z which is to run it non-interactively and the -f flag takes the argument of the log file location.

Ok, reboot the mac and see if airconnect is going to be ran during launch.

Setting up on Linux

Ok, this is my prefered system, and if you have some spare computer running linux you can use this. Alternatively, you can also use a raspberry pi for this, it should work the same.

You can choose to download only the binaries for linux, but I chose to clone the entire repository instead.

Clone the repository into your /etc/airconnect folder with the following command.

$ git clone https://github.com/philippe44/AirConnect.git /etc/airconnect

Next, make sure the binary is executable with the following.

$ chmod +x /etc/airconnect/bin/airupnp-x86-64

Finally, check that it works by running the application.

$ /etc/airconnect/bin/airupnp-x86–64

To automate the start of the script, we’ll use the method recommended in the repository, by using systemd.

Create a file airconnect.service in the /etc/systemd/system/ folder.

$ nano /etc/systemd/system/airconnect.service

The contents of the file will be, take note that I omitted the log file and config file here, if you would like add them as flags to the command.

[Unit]  
Description=AirUPnP bridge
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/etc/airconnect/bin/airupnp-x86-64
#if using raspberry pi, use /etc/airconnect/bin/airupnp-arm instead
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

Next, enable the service with,

$ sudo systemctl enable airconnect.service

And finally, start the service,

$ sudo service airconnect start

To view the log file you can use,

$ journalctl -u airconnect.service

That’s all, if you reboot the device, the script will start automatically.

Finally, you can also get this to work on Windows 10, but I haven’t done it myself. Leave me a comment if you would like me to write about this.

References

An avid web developer constantly looking for new web technologies to dabble in, more information can be found on bit.ly/jayden-chua

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store