Just received my new Sonos Move and try to integrate it into my openHAB environment.
When executing a TTS command, the notification is played, but music will not continue afterwards:
Thats my script to test the notification (based on the blockly :
var voice = Java.type('org.openhab.core.model.script.actions.Voice');
voice.say('Hallo, wie geht es dir?', 'picotts:deDE', 'sonos:Move:MoveWohnzimmer');
Thats whats happening in the log if I send the notification:
2023-06-25 10:45:11.210 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 21 to 30
2023-06-25 10:45:11.273 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to STOPPED
2023-06-25 10:45:11.275 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-25 10:45:11.489 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from a954076a-ad96-484d-a6f7-1fcf4ca0545e.wav to 7637981b-16c5-48ca-b0fa-10ec5d9a690d.wav
2023-06-25 10:45:11.492 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from a954076a-ad96-484d-a6f7-1fcf4ca0545e.wav to 7637981b-16c5-48ca-b0fa-10ec5d9a690d.wav
2023-06-25 10:45:11.565 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-25 10:45:11.568 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
2023-06-25 10:45:13.769 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to STOPPED
2023-06-25 10:45:13.775 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-25 10:45:13.914 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 30 to 21
Whats missing that the sonos will automatically continue music after the notification is played?
Such might be caused by the used “music” before starting the TTS command. From which source did you get this “music”, how did you start it ( Sonos UI, Echo device etc…) Giving these details will help to find the cause.
You are right, thats something I have not recognized before.
If I start spotify via Sonos app, than its working as expected:
Music is playing, I can send a notification and music will continue afterwards.
However if I
start music via spotify app
ask alexa to play from spotify
ask alexa to play radio
music will stop and not continue after the notification.
I am wondering if I am missing something?
Is it expected, that music will resume after a notification? (Can others confirm?)
Is there something I should configure either within OH or the sonos app, that I have missed?
Should I send a notification in a different way?
Yes, it should. However, it seems to make a difference for the binding how the music is started ( note that the Sonos app sometimes displays how the music was started). I did observe the same in the past (other source) an the author was able to solve it back then.
You migth file an issue on Github openhab addons to raise the interest of a volunteer.
That’s a valid point.
I would expect, that current played music is not stopped, but volume lowered and the notification is played on top of this. But unfortunately real life shows different behavior.
I used an echo device before and wanted to migrate to Sonos; if notifications are not working as expected that’s definitively a no-go
I did some more tests and at least the scenario Alexa → Radio on sonos & playing notification is working now:
Before the radio was played via ARD Mediathek skill and not working, but when using tunein, sonos is able to automatically restore the radio.
However for spotify it is still not working as expected.
What I recognized so far:
If I start spotify via alexa or via the spotify app, the playlist within the sonos app remains empty and that’s my log:
at 13:38:02 I started spoitfy via the app
at 13.38:12 is run the rule to send a notification
spotify music started via spotify app - not working
2023-06-26 13:38:02.142 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_AV_Transport_URI' changed from x-rincon-queue:RINCON_C438752586EC01400#0 to x-sonos-vli:RINCON_C438752586EC01400:2,spotify:4d84c5215e7d45bc2f471ebb83b15cc0
2023-06-26 13:38:02.182 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from 799c543b-c872-4b55-a285-e019103623c6.wav to Never Going Home
2023-06-26 13:38:02.185 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from 799c543b-c872-4b55-a285-e019103623c6.wav to Kungs - Never Going Home - Never Going Home
2023-06-26 13:38:02.189 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-26 13:38:02.191 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
2023-06-26 13:38:12.529 [INFO ] [openhab.event.RuleUpdatedEvent ] - Rule '729774ed7a' has been updated.
2023-06-26 13:38:14.115 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to PAUSED_PLAYBACK
2023-06-26 13:38:14.118 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-26 13:38:14.463 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_AV_Transport_URI' changed from x-sonos-vli:RINCON_C438752586EC01400:2,spotify:4d84c5215e7d45bc2f471ebb83b15cc0 to x-rincon-queue:RINCON_C438752586EC01400#0
2023-06-26 13:38:14.506 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from Never Going Home to ca52e587-5fe9-482a-9960-7be89a1a656a.wav
2023-06-26 13:38:14.513 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from Kungs - Never Going Home - Never Going Home to ca52e587-5fe9-482a-9960-7be89a1a656a.wav
2023-06-26 13:38:14.516 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PAUSED_PLAYBACK to STOPPED
2023-06-26 13:38:14.534 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 17 to 30
2023-06-26 13:38:14.608 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-26 13:38:14.613 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
2023-06-26 13:38:16.563 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to STOPPED
2023-06-26 13:38:16.574 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-26 13:38:16.886 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 30 to 17
However if I start spotify via sonos app, than the playlist is not empty and the music will continue:
spotify music started via sonos app - working
2023-06-26 13:41:34.620 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from ca52e587-5fe9-482a-9960-7be89a1a656a.wav to The Sweetest Taboo - Remix
2023-06-26 13:41:34.625 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from ca52e587-5fe9-482a-9960-7be89a1a656a.wav to Scubba - The Sweetest Taboo (Remix) - The Sweetest Taboo - Remix
2023-06-26 13:41:36.116 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-26 13:41:36.119 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
2023-06-26 13:41:45.098 [INFO ] [openhab.event.RuleUpdatedEvent ] - Rule '729774ed7a' has been updated.
2023-06-26 13:41:46.789 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to STOPPED
2023-06-26 13:41:46.795 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-26 13:41:47.059 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from The Sweetest Taboo - Remix to d129bd2b-dca9-4d69-a9bb-34f5dd77ed25.wav
2023-06-26 13:41:47.061 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from Scubba - The Sweetest Taboo (Remix) - The Sweetest Taboo - Remix to d129bd2b-dca9-4d69-a9bb-34f5dd77ed25.wav
2023-06-26 13:41:47.063 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-26 13:41:47.066 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
2023-06-26 13:41:47.078 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 17 to 30
2023-06-26 13:41:48.982 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Titel' changed from d129bd2b-dca9-4d69-a9bb-34f5dd77ed25.wav to The Sweetest Taboo - Remix
2023-06-26 13:41:48.986 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Track_Name' changed from d129bd2b-dca9-4d69-a9bb-34f5dd77ed25.wav to Scubba - The Sweetest Taboo (Remix) - The Sweetest Taboo - Remix
2023-06-26 13:41:48.990 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from PLAYING to STOPPED
2023-06-26 13:41:48.996 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PLAY to PAUSE
2023-06-26 13:41:49.228 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Lautstarke' changed from 30 to 17
2023-06-26 13:41:50.311 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Status' changed from STOPPED to PLAYING
2023-06-26 13:41:50.319 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonos_Move_Wohnzimmer_Mediacontrol' changed from PAUSE to PLAY
Side note: If I start playlist via spotify app, but there are different songs in the playlist of the sonos app, after sending a notification, sonos will continue to play music, but as per its own playlist and not the playlist from the spotify app, what was active before.
I did some more research and testing:
In the home assistant docu it says
Playing TTS (text-to-speech) or audio files as alerts (e.g., a doorbell or alarm) is possible by setting the announce argument to true . Using announce will play the provided media URL as an overlay, gently lowering the current music volume and automatically restoring to the original level when finished. Sonos - Home Assistant (home-assistant.io)
I have installed home assistant on a VM, my sonos speaker was automatically discovered and TTS was working as expected for all scenarios.
As it is working with home assistant, but not with openhab, it seems to be related to the binding and not something “impossible”
I’m not sure if my programming skills are good enough for contribution. If there is something that I can test, provide log file etc I’m happy to support.
As per the docu get an authorization key, access token & refresh token (Authorize)
(access token is only valid for certain time and should be renewed with the help of the refresh token)
Steps to send an actual notification:
get the relevant household id (documentation: Discover)
get player id based on household (documentation same as above)
send audio clip to specific player (documentation: loadAudioClip)
Thats working as expected:
Independent what you play, volume is decreasing, mp3 file played, after the announcement volume will increase again and music will continue
What I do not know:
The API requires a URL; for testing I used a fixed sound file uploaded to the OH html folder, but I do not know how to dynamically use the TTS service to retrieve an URL for mp3 / wav result of the TTS
I have no clue on how to contribute this to the binding. I could maybe store access token & refresh token in 2 string items and have A) a rule to automatically refresh the tokens once a day and B) sending the audio clip request via another rule, but both would be difficult for others to reuse and would not be part of the binding
If I correctly understand, you are using a Sonos API not yet supported by the Sonos binding, an API requiring an internet access I assume.
Using this API would be probably a major change/refactoring of the binding.
Yes he is talking about their cloud API . I believe is not the right way to go about this by adapting the Sonos binding for their API but a rule would make more sense they even have examples of how to implement in javascript
When testing home assistant it immediately worked out of the box after installation, WITHOUT logging into sonos cloud and using the official API. Thats indicating to me, that there is also another way to achieve the same.