Created At
Feb 08, 2022
Created By Joep Verhaeg
Automatically control, group and ungroup your Sonos players
Created At
Feb 08, 2022
Last Update
Dec 02, 2024
Platforms
HC 3 Lite, Z-box Hub, Yubii Home Pro, Venture WISE, HC 3
Views
6207
Download
573
The Sonos Automation Controller Quick App is the upgraded and improved replacement for this Quick App. With support for the latest Sonos S2 JSON API, this new Quick App provides a better integration with your HC3.
This Quick App will soon be removed from the marketplace, so I recommend transitioning to the new version.
---------------------------------------------------------------------------------------------------------
There are some Sonos Quick Apps already available for the Home Center 3, but none of them can group and ungroup Sonos speakers.
This Quick App that has little to no impact on your network because it doesn't use polling for status. It is made for use in Lua scenes or other Quick Apps and has a minimal GUI that can be refreshed manually.
From a Lua scene (or Quick App) you can:
Sonos stores playlists, InTunes stations and albums in My Sonos in alphabetical order. You cannot adjust this. The first 4 items are shown, but you can play all favorites easily which I show you later on.
With the following code examples I'll show you how you can use the Sonos Group Controller Quick App to fully automate your music expecience in your smarthome:
In all examples the variable qaId
is the ID
of your Quick App.
fibaro.call(qaId, "savePlayStateAndPause")
|
Useful in presence detection automations where you want to save the state of your players and automatically pause all players when everybody left the house.This command saves the current player state (like PLAY/STOP) and pauses the player.
fibaro.call(qaId, "setPreviousPlayerState")
|
Useful in presence detection automations where you want to automatically set the previous state of your players when the first person arrives at home.This command retrieves the previous saved player state (like PLAY/STOP) and turns the speaker back on if it was playing music.
fibaro.call(qaId, "playFavorite", "title", "15")
|
Easily play a favorite from the My Sonos list by using the title of the favorite. The second parameter is the volume at which you want to play this favorite. First the volume is set before the favorite is played, so that you are not surprised with a loud volume from a previous listening session.
local playerSource = "x-rincon:" .. fibaro.getValue(1001, "model")
fibaro.call(1002, "playFromUri", playerSource , "")
|
With this command you can add a player to a group (or create one). Use the playerUuid
from the speaker that is currently playing the music (the group master).
In this example the livingroom speaker with an id
of 1001
is playing and you want to create a group with the kitchen speaker (with an id
of 1002
). You first contruct the Uri with the id
from the livingroom speaker and then add this Uri to the kitchen speaker. Now the Sonos System creates a group.
fibaro.call(qaId, "LeaveGroup")
|
When you send this command to a Sonos speaker it automatically leaves the group it is in.
fibaro.call(qaId, "configureSleepTimer", "23:15:00")
|
When you send this command to a Sonos speaker it turns off the music at 23:15 (Sonos sleep timer function).
You can read the full documentation of the Sonos Group Controller Quick App at:
https://docs.joepverhaeg.nl/sonos-group-controller/
@Martijn, it took a while, but this morning the QA is approved and available again. Have fun!
@Joep Thanks for providing an update. Can't wait to test the new version when it comes online. Appreciated if you can spend a posting here if the file becomes available for us!
@Remko Meijer, I pushed an update two days ago and Fibaro has to approve it. Until that time it seems that the link is offline :(
Hi Joep, sorry to bother you, but i cannot find the new QA: https://marketplace.fibaro.com/items/sonos-s2-automation-controller Do you have any idear where to get this? Thank you!
Many thanks Joep! Working on it already :-)