"SonosAmpJuicePi"- solution for automatically powering on/off amps

  • 3 November 2016
  • 8 replies
  • 2835 views

Badge
I recently completed a four-room setup in my home that required that multiple centrally-located amplifiers be powered on and off automatically based on what their corresponding Sonos Connects were up to. My solution is centered on a Raspberry Pi 2 and a dusting of code on top of the summit built buy @jishi from this forum. I have attached a photo of what it physically looks like in my case. And here a copy of the Readme from the code's GitHub page. I hope others may be able to benefit!

https://github.com/geeeyetee/SonosAmpJuicePi

SonosAmpJuicePi



Purpose


The purpose of this application is to turn power off and on at the mains for centrally-located amplifiers/receivers, using GPIO pins on the Raspberry Pi connected to relays (such as the PowerSwitch Tail).

App.js


  • Edit the `amps` variable to associate each of your sonos player/room names with a GPIO physical pin number (which you in turn have connected to a relay that controls power to the corresponding amplifier).
  • Edit the `stopTimeout` variable if you want to change the delay between when the application learns that an amp can be turned off and when it does so.
  • Change the value of the `justTestingOnSomeDeviceThatLacksGpio` variable to `true` if you want to test the application on your PC (by running node and watching log files and/or command-line output).

Notes


  • Responds appropriately to grouping, ungrouping, muting, pausing, stopping, playing, turning the volume all the way down to zero, and increasing the volume from zero
  • Controls each player's amplifier as appropriate, whether or not it is currently part of a group
  • Turns amplifiers on instantly when they are needed; turns them off after `stopTimeout` when they are not. `stopTimeout` will reset while users are making any additional changes such as pausing or starting and adjusting volume.
  • Runs reliably and long-term on the author's Raspberry Pi 2
  • Does not account for setups that include the Sonos Sub or Playbar, or that use stereo pairing (using one player for the left channel and another for the right)
  • A player's amplifier may turn on upon being added to a group even when the group is not playing anything. It will turn off after `stopTimeout` if the group does not begin playing something in the meantime.

Pre-composed raspberry pi image


  • Download URL: https://github.com/geeeyetee/SonosAmpJuicePi/releases/download/v1.0/SonosAmpJuicePi.img.gz
  • Windows users, you can extract the .img file from this .gz archive using the free 7zip application.
  • This is a ready-to-run image for Raspberry Pi 2 (it should also work on Pi B/B+ and 3).
  • The image is clumsily adapted the one Jimmy Shimizu links to from https://jishi.github.io/node-sonos-http-api/, so here are helpful instructions lifted from the same page: [quote] - By default the root user has no password, if you want to set a password, just SSH to that machine and set a new root password. - It also has samba installed by default, and sharing the /flash folder with read/write permissions for easier access. Just visit \\sonos from a windows machine or smb://sonos from macOS (replace sonos with the IP if it doesn't work). - To write the image to an SD-card, use the`dd` command on Linux and OS X, or Win32DiskWriter on Windows. [/quote]
  • Set up your room names etc. as specified above by editing `\\sonos\flash\apps\SonosAmpJuicePi\app.js` / `smb://sonos/flash/apps/SonosAmpJuicePi\app.js`
  • Then restart the Pi and wait a few minutes for network discovery to complete.
  • To troubleshoot, open the latest file in `\\sonos\flash\logs` / `smb://sonos/flash/logs`.

Acknowledgement


This is a trivial hack with a result that its author finds incredibly useful. It only exists because of the yeoman's work done by Jimmy Shimizu (https://github.com/jishi/). Thank you, Jimmy!!!

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

8 replies

Userlevel 3
Badge +2
Amazing work
Badge
Thanks! 🙂
Userlevel 4
Badge +14
Fun to see someone finding it useful!

I'll give you a few pointers on github on stuff you might want to look into.
Badge
Much appreciated!
Userlevel 1
I found this and loved the idea. I got a RPi 3b and loaded it up but it doesn't work. It boots fine and, per the log file, clearly locates my Sonos Connects. But, no change to the play state of any connect in my system results in recognition on the RPi, per the log file. And, I can see the GPIO is not being triggered.
I tried a "npm install" on the main package.json file to see if any updates would help. It resulted in lots of error on rpio and nothing worked after (no more debugging done yet).
Any ideas why I'm having these challenges? Did Sonos change something to make this unusable? Do I need to update only one of the packages to make it work?

I would also add, I've been trying to get this up on a RPi Zero W. The v3.4.0 AlpineLinux it's based upon doesn't work on a RPi Zero W. The earliest working version I've found is 3.6.0. I haven't fully fiddled with which packages your version has installed vs my 1st attempt but basically it didn't work yet. Any chance you have a version of SonosAmpJuicePi working on a newer version of AlpineLinux?
Badge
SonosAmpJuicePi still works great in my home with the latest Sonos software. I have not updated AlpineLinux.

I’d be happy to try to help troubleshoot your RPi 3b. The best way would be for you to create an issue on GitHub. Did you edit the amps variable in App.js to associate each of your sonos player/room names with a GPIO physical pin number?
SonosAmpJuicePi still works great in my home with the latest Sonos software. I have not updated AlpineLinux.

hi geeeyetee,

first of all thank you 0 this seems a solution to my problem and i very much would like to set this up for my sonos connect and pioneer amp. i have a spare pi and have built many diverse pi machines.

but cannot find a power switch tail anywhere bc they are no longer being made:
http://powerswitchtail.com/contact-us

do you suggest an alternative?
would this work?
https://www.amazon.com/Iot-Relay-Enclosed-High-Power-Raspberry/dp/B00WV7GMA2

thanks for any advice or help you can provide.
Mr.B
Badge
@Mr.B - That looks like it should work very well. Good luck, and please let me know how it goes!