Created At

Feb 08, 2022

Last Update

Jan 20, 2023

Platforms

HC 3 Lite, Z-box Hub, Yubii Home Pro, Venture WISE, HC 3

Views

4676

Download

471

Type Quick App

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.

Release notes

v1.4.0

  • Added function to set a sleep timer on your Sonos player with a Lua scene.

v1.3.0

  • Fixed QuickApp crash when Explore Sonos Radio was set as a favorite.

v1.2.0

  • Fixed QuickApp crash when a favorite has no metadata.
  • Fixed an error in the documentation.

v1.1.0

  • Fixed QuickApp crash when less than 4 favorites.
  • Fixed saved playback state incorrect when player becomes offline.
  • Fixed an error in the documentation.

Possibilities

From a Lua scene (or Quick App) you can:

  • Start a Sonos Favorite at a specified volume.
  • Set the volume of a Sonos speaker.
  • Save the player state (like PLAY/STOP) and automatically pause.
  • Get the previous player state and resume this state.
  • Create or add a Sonos speaker to a group.
  • Remove a Sonos speaker from a group.
  • Set a sleep timer on the Sonos player.

My Sonos list notice

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.

Usage in Lua scenes

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.

E.g. 1: Save Sonos player state when everybody left the house

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.

E.g. 2: Set the previous Sonos player state when the first person arrives at home

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.

E.g. 3: Play a My Sonos favorite at a specific volume

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.

E.g. 4: Add the Sonos player to a group (or create a new one)

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.

E.g. 5: Remove the Sonos player from a group

fibaro.call(qaId, "LeaveGroup")

When you send this command to a Sonos speaker it automatically leaves the group it is in.

E.g. 6: Set a sleep timer on a Sonos player

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).

Full documentation

You can read the full documentation of the Sonos Group Controller Quick App at:
https://docs.joepverhaeg.nl/sonos-group-controller/

11 Comments,  Want to add comment please login
7e55719745ae9e37e0996f355585fffc

Thank you. Now it just saves play/pause state and not the current playing song. Give me 2 a 3 weeks from now to start implementing what you want, because of the summer activities with my family at the moment. 😎

F6cae75914b7c403d9d0fddb99d3598a

Hello - LOVE this QA, been looking for something like this - I nearly gave up! Wondering if it would be possible to save the state and recall it? Target solution: 1. Get & save state 2. Play MP3 (Doorbell) 3. Resume saved state Idea being is that if Sonos is currently playing "something" it will resume after playing the doorbell mp3. Big fan of your smart home adventure too :)

Aac3beb6942c62b870ab0dddb3a505d4

Hello. Great QA! But it is possible to get the current state of a Sonos speaker? I would like to call something like: Fibaro.getvalue(qaID, "state") to get the state of the speaker so I can control play/pause from one button. If the speaker is paused = play and if the speaker is playing = pause. Thank you very much :-)

Cee99fe938ec3f651b60a6929cf1160c

Great job!!

7e55719745ae9e37e0996f355585fffc

@Jeroen L: please send me an e-mail with the code you use in the scene (my e-mail address is in de QA header). With just this info about the sleep timer its very hard to help. Please note that support is limited, I'm not a support desk.

© 2024. Nice-Polska Sp. z o.o.Privacy policyTerms & ConditionsFeedback