This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to

This forum is now read-only for archive purposes.

Better Sonos support for Homey through raspberry pi

JschuetzJschuetz Member
edited September 2017 in Ideas & Suggestions
Hey everyone,

homeys Sonos support is very limited. But i find a good solution to control my sonos speakers with homey and node-sonos-http-api. Now i can set playlists, favourites or let my sonos speakers say something in many languages. It's very cool!

Cause now i can turn my sonos speakers completely off without loosing the favourites. Or i  can use all my speakers in my house to remind me. Here you can use the remind tags.


  • Only teasing us? Or are you going to enlighten us with how you did it?
  • JschuetzJschuetz Member
    edited January 2017
    I am using a Raspberry Pi for MagicMirror and Sonos-Node-HTTP-API.

    On my PI

    Now you can control your system by invoking the following commands:

    http://localhost:5005/pauseall[/{timeout in minutes}]
    http://localhost:5005/resumeall[/{timeout in minutes}]
    http://localhost:5005/preset/{JSON preset}
    http://localhost:5005/preset/{predefined preset name}
    http://localhost:5005/{room name}/sleep/{timeout in seconds or "off"}
    http://localhost:5005/{room name}/sleep/{timeout in seconds or "off"}
    http://localhost:5005/{room name}/{action}[/{parameter}]

    The actions supported as of today:

    • play
    • pause
    • playpause (toggles playing state)
    • volume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
    • groupVolume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
    • mute / unmute
    • groupMute / groupUnmute
    • togglemute (toggles mute state)
    • trackseek (parameter is queue index)
    • timeseek (parameter is in seconds, 60 for 1:00, 120 for 2:00 etc)
    • next
    • previous
    • state (will return a json-representation of the current state of player)
    • favorite
    • favorites (with optional "detailed" parameter)
    • playlist
    • lockvolumes / unlockvolumes (experimental, will enforce the volume that was selected when locking!)
    • repeat (on/off)
    • shuffle (on/off)
    • crossfade (on/off)
    • pauseall (with optional timeout in minutes)
    • resumeall (will resume the ones that was pause on the pauseall call. Useful for doorbell, phone calls, etc. Optional timeout)
    • say
    • sayall
    • queue
    • clearqueue
    • sleep (values in seconds)
    • linein (only analog linein, not PLAYBAR yet)
    • clip (announce custom mp3 clip)
    • clipall

    After that you have to choose your TTS Provider.

    Experimental support for TTS. Today the following providers are available:

    • voicerss
    • Microsoft Cognitive Services (Bing Text to Speech API)
    • AWS Polly
    • Google (default)

    I am using the voicerss. For this you have to register for the free api key. Then you create a settings.json in your node-http path.

    Change your API key in the json file.
      "voicerss": "f5e77e1d42063175b9219866129189a3"
    After that you can use the http app of homey.

    One example flow for music in my bath room:

    For the play part i have set an delay of 1 second. This is necessary to give the sonos first the playlist. Cause it was powered off and if this happens the speaker will loose the last position. This is default you can try it with your own speaker, turn the power complete off and then connect it again with the socket and push play. Nothing will happens cause the speaker must have a queue. And a queue will only saved in the speaker standby modus.

    But with the http get command i give him a radio station. Attention: You must have favourites in your sonos app. Radio

    I have many sonos speakers and the standby power consumption   should not be underestimated. Thats the reason why i turn some of them complete off.

    But thats not all, you can use the commands sayall for textspeech on all zones or clipall (own mp3 file) without  to group them first. If you wanna use one of this commands only on one zone you can use: ist fertig /de-deüro/say/Essen ist fertig /de-de

    for voicerss:

    hostname:5005/roomName/say/Text to speech or with tag/languageCode

    I don't testet the json part of the http homey app. But normaly you should be able to ask homey about the song in room xxx and with the http homey app you can ask the node-http-api for the current track.


  • Is there some way this be run on Homey without using additional hardware like the Rasperry Pi?
    And do I understand it right, that it makes it possible to play radio? Not only favourites/playlists?
  • probably by creating a server like @swttt did for HomeyDash
  • Where homeydash isn't using an express server anymore ;)
  • nice tutorial thanks but for others i will make a side note.Your raspberry needs node 4.0.0 or higher otherwise you will get an install failure
    on my rasp 3 i did the following
    curl -sL | sudo -E bash -
    sudo apt-get install -y nodejs 
    sudo apt-get install -y build-essential

    after that i could start the server

  • Where NVM (node version manager) is a handy tool as well..
  • Just sitting her hoping Athom will make further development and integration of the Sonos-app a priority.

    To somebody with absolutely no experience in raspberry and coding in general it is a bit of a challenge and rather timeconsuming to get an overview and figure out what to do (even with all the help everybody provide - and thank you for that!). 
  • The spotify connect beta app might do the trick ;)
  • For those running Spotify, I guess...
    I'm running "Telmore Music" (part of my cellphone subscription...)
  • Hi Homey friends

    i would love to control my Sonos like my otter devices, without the Homey Sonos app which takes over the control of the Sonos media manager (what because of multiple reasons I don’t want). 

    There is the HTTP app and the Homeyscript app. Did someone test if you can control Sonos with it, without using the raspberry pi setup? 

    That would be perfect and give much more control with Sonos
  • This is amazing! Thanks a lot for posting this. I can use this to finally create a smart music assistant by using API.AI, Google Home, Homey and this library :).
  • People with a RP1, make sure to have installed Node 6. @satbopper 's solution doesn't work for the RP1, instead, use:
Sign In or Register to comment.