Sonos Snapshots and the Doorbell mp3 + NodeRED

SO I have a weird problem which appeared recently in one of the 0.116 releases (I think), it’s anyway been working for months before this without issues.

I have a flow in NodeRED for when someone pushes the doorbell:
Sonos snapshot -> set volume -> play mp3 doorbell -> restore snapshot

However recently, it seems like it makes the snapshots, the audio will pause to play the sound… but nothing happens, then the state is restored again…

Playing the sound directly without doing the snapshots still works correctly every time, so I figured something must be wrong with the snapshot… BUT I have the exact same setup for TTS with Google Cloud, and this still works 100%:
Sonos snapshot -> set volume -> Google TTS -> Restore snapshot

So… now I’m stumped… I switched the URL for the mp3 to my NabuCasa URL (so that it’s https) instead of the local one, but that made no difference at all (wasn’t really expecting any change). It’s as if, only for this, the flow is not waiting for the sound to finish playing before restoring the snapshot.

Ideas?

For now, I just put in a delay after the “play” command for the same length of time that the mp3 is and this seems to be working…

Hi,

sorry I do not know the Sonos snapshot… but I use this node and it still works … pauses the playback and plays the file and picks up again… - hope this helps

[{"id":"95d7c2f9.35862","type":"inject","z":"bd13025a.d0f78","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":170,"y":280,"wires":[["96863c26.405"]]},{"id":"7c373c4.d09e9c4","type":"sonos-universal","z":"bd13025a.d0f78","confignode":"707ba1d8.b4224","name":"Buero","x":850,"y":260,"wires":[["2167512c.db220e"]]},{"id":"96863c26.405","type":"function","z":"bd13025a.d0f78","name":"Sonos- Klingelinfo /backup","func":"msg.payload = \"play.notification\";\nmsg.volume = \"40\";\nmsg.topic = \"http://192.168.1.XXX:8123/api/tts_proxy/XXX-_google_translate.mp3\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":555,"y":271,"wires":[["7c373c4.d09e9c4"]]},{"id":"2167512c.db220e","type":"debug","z":"bd13025a.d0f78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1390,"y":180,"wires":[]},{"id":"707ba1d8.b4224","type":"sonos-config","z":"","name":"MySonosBuro","serialnum":"XX-XX-37-E7-DC-A0:3","ipaddress":"192.168.1.XXX"}]

Hello :slight_smile:
Were you able to solve this? I’m looking to implement the same automation.

I’d really appreciate any help you could share

Cheers

Hi there,
So far I am able to stop my queue, play my doorbell sound, but it does not resume the last played queue. I did some research and found out about the snapshot and restore feature.
How in Node Red do you use the snapshot and restore function? I looked through the list, but cannot find anything like this.
Are you able to point in the right direction on how implement this snapshot and restore feature ?
Thanks

@Travion You need to call a service in the sonos domain, with the snapshot / restore service.

Yes / no. I just use the NabuCasa URL in the data field:

{"media_content_id":"https://xxxx.ui.nabu.casa/local/audio/doorbell-1.mp3","media_content_type":"music"}

I checked how long the sound is, and just put a delay in of more or less that amount of time to do the restore. Delay may not be needed anymore, it’s been working like this without issues for so long, but it’s at least a fallback.

Ok great, thank you so much for the information. I will take a look at this tomorrow and let you know if it works.

Everything works fine except the restore function. I receive the error message :
“HomeAssistantError: Restore failed, speakers are missing snapshots: [‘Kitchen’]”

I have played around with the data field : {“with_group”:true} I have also tried putting this to false, leaving it out etc , but htis does not help.
It seems that the restore cannot find the snapshot it took.

For the snapshot and restore, are you calling the correct Sonos “room”?

In my example above, I had “Sonos Five” which is actually the group/room for my two Sonos 5 speakers.

I mean, it only shows me the groups in HomeAssistant, not the individual speakers, so you should be picking the right thing.

The only thing I can really pick is the SONOS let’s say as in my example kitchen.
In the list it’s named media_player.kitchen.
It doesn’t show any other names such as groups etc.
Screenshot 2024-03-25 at 14.56.46

Should be fine :person_shrugging:

For reference, I’ve tested the following combinations:

  • 2x Sonos Five
  • Sonos Arc + Sub + 2x One’s

I don’t think it’s a NodeRED problem specifically.
Have you tried doing the same from HomeAssistant developer tools in the UI?

I suppose one difference is that I’m still playing the media with HomeAssistant, where as it looks like you are using some other NodeRed specific thing.