While Sonos is a great solution for wireless speaker it sometimes lacks the support of a remote control. For easy tasks as play/pause, volume up/down, next/previous song it is easier to press a button on a remote than fiddling on your phone.
With just a Raspberry Pi and an old apple remote (or any other remote) this is quite easy to achieve.
Components used:
Connect your Sensor to 3.3V, GND and GPIO 18. Please refer to the excellent Adafruit Tutorial to see an illustration.
If you are using another remote check the list and edit lircd.conf
and lircrc
accordingly.
The install script install.sh
is a convenient way for automatic install of all required software and configuration of the system. For detailed instructions refer to the next section.
git clone https://github.com/prebm/SonosRemote.git
install.sh
with root privileges
sudo ./install.sh
The following section describes how to install the IR Receiver Sensor and the required software to your Raspberry Pi. At the end, there is a part with instructions how to enable the daemon for automatic start at boot for older versions of Raspbian with init.d and newer versions (starting with Jessie) with systemd.
Please refer to the link section at the end of this Readme. It contains useful links for troubleshooting.
sudo apt-get install git
sudo apt-get install python-pip
lirc
:
sudo apt-get install lirc
python-lirc
:
sudo apt-get install python-lirc
SoCo
:
sudo pip install soco
/home/pi/SonosRemote/
. If you choose another path to your files, be sure to change the paths respectively.
git clone https://github.com/prebm/SonosRemote.git
I am running Raspbian 8.0 with the Kernel 4.4, for Kernels before 3.18 one step is different
uname -a
):
/boot/config.txt
and uncomment the line
dtoverlay=lirc-rpi
/etc/modules
:
lirc_dev
lirc_rpi
/etc/lirc/hardware.conf
LIRCD_ARGS="--uinput"
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
lircd.conf
to /etc/lirc/
- or search your remote from the listlircrc
to /etc/lirc/
- edit accordingly if you are using another remotesudo reboot
config.py
:
$ get_sonos_ip.py
Player: Kitchen at IP: <SoCo object at ip 192.168.1.46>
sore.py
is executable
sudo chmod +x sore.py
sore
to /etc/init.d
and edit the paths if necessary/etc/init.d/sore
executable
sudo chmod +x sore
sudo update-rc.d sore defaults
sore.service
to /etc/systemd/system/
and edit the paths if necessary
sudo cp sore.service /etc/systemd/system/
/etc/systemd/system/sore.service
has the required rights
sudo chmod 664 sore.service
sudo systemctl daemon-reload
sudo systemctl enable sore.service
We installed a service to run at boot. So after booting your Raspberry Pi everything should work out of the box. You can use the following commands:
sudo systemctl status sore.service
sudo systemctl start sore.service
sudo systemctl stop sore.service
sudo /etc/init.d/sore start
sudo /etc/init.d/sore stop
sudo /etc/init.d/sore restart
sudo /etc/init.d/sore status
I have added a basic logging mechanism which logs to sore.log. To save disk space it is deactivated. Activate it and check the logs for any useful messages by uncommenting the following line in sore.py
# logging.basicConfig(filename="/home/pi/SonosRemote/sore.log", level=logging.INFO)
If the service is not starting up at boot, try to restart it manually. It is a known issue that the startup at boot is not working if you are running Jessie.
LIRC
https://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/
http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/
Sonos
Service