I’m currently also facing some issues with the sonos.restore option.
I’m using node-red flow to take a sonos-snapshot of the kitchen speaker, then play a file via TTS and do some more stuff and next use the sonos.restore to resume playback.
BUT here is the problem: when there is no music playing on the kitchen speaker and I trigger the TTS then the sonos.restore always kicks in and resumes playing the previous audio even when there was no audio playing at the moment of the sonos.snapshot.
You get what I mean?
If there was music (spotify or tunein radio) playing at the moment of the sonos.snapshot this is resumed correctly with the sonos.restore.
My only issue is when there is NO music/audio playing the sonos.restore will always resume playback.
Any tips?
Here is my node-red flow:
[{"id":"bfc686bb.a45ca8","type":"trigger-state","z":"ebbc7cb3.0c2d5","name":"snoepla","server":"779066dc.805a78","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.rfxcom_doorwindowsensor_5_snoepla","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"woiwqxlz357","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":100,"y":740,"wires":[["9fe59670.3168d8","3fcbe9fa.b624e6"],[]]},{"id":"9fe59670.3168d8","type":"time-range-switch","z":"ebbc7cb3.0c2d5","name":"6am and 11pm","lat":"52.00472","lon":"5.92784","startTime":"06:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":340,"y":740,"wires":[["a327d743.a530c8","1ee009cb.b1b676"],["a327d743.a530c8"]]},{"id":"3fcbe9fa.b624e6","type":"debug","z":"ebbc7cb3.0c2d5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":330,"y":840,"wires":[]},{"id":"a327d743.a530c8","type":"function","z":"ebbc7cb3.0c2d5","name":"create payload","func":"msg.method = \"sendPhoto\";\nmsg.payload = {\n photo: \"/config/www/snapshots/snapshot_cam5_keuken.jpg\",\n caption: \"CAM4 - de snoepla is open!\"\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":740,"wires":[["b64bffe.ace1"]]},{"id":"1ee009cb.b1b676","type":"change","z":"ebbc7cb3.0c2d5","name":"prompt","rules":[{"t":"set","p":"tts1","pt":"flow","to":"ALARM! ALARM! Wie steelt er lekkers uit de la?","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":800,"wires":[["cc21a765.8010b8"]]},{"id":"b64bffe.ace1","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"Save snapshot cam5","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"camera","service":"snapshot","entityId":"camera.me_cam5_keuken","data":"{\"filename\":\"/config/www/snapshots/snapshot_cam5_keuken.jpg\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":760,"y":740,"wires":[["452a4c54.ac3f94"]]},{"id":"cc21a765.8010b8","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"unjoin","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"sonos","service":"unjoin","entityId":"media_player.keuken","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":800,"wires":[["ffbdd0a5.e7b5"]]},{"id":"452a4c54.ac3f94","type":"delay","z":"ebbc7cb3.0c2d5","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":740,"wires":[["7e5d18da.7ff7a8"]]},{"id":"ffbdd0a5.e7b5","type":"api-current-state","z":"ebbc7cb3.0c2d5","name":"sonos state","server":"779066dc.805a78","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.keuken","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":790,"y":800,"wires":[["130678db.af1027"]]},{"id":"7e5d18da.7ff7a8","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"notify simon","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_isims","entityId":"","data":"{\"title\":\"Beweging gedetecteerd!\",\"message\":\"De snoepla is geopend.\",\"data\":{\"push\":{\"badge\":1,\"category\":\"respond_doorbell\"},\"attachment\":{\"url\":\"http://xxx.xxx.xxx.xxx/picture/5/current/?_username=xxxx&_signature=xxxxxxxxxa\",\"content-type\":\"jpeg\",\"hide-thumbnail\":false}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1210,"y":740,"wires":[[]]},{"id":"130678db.af1027","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"pause","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_pause","entityId":"media_player.keuken","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":930,"y":800,"wires":[["c2ae5e48.25411"]]},{"id":"c2ae5e48.25411","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"snapshot","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"sonos","service":"snapshot","entityId":"media_player.keuken","data":"{\"with_group\":\"true\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1060,"y":800,"wires":[["f36ec39d.0738c"]]},{"id":"f36ec39d.0738c","type":"delay","z":"ebbc7cb3.0c2d5","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":670,"y":860,"wires":[["447b78ec.338058"]]},{"id":"447b78ec.338058","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"volume 50%","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.keuken","data":"{\"volume_level\":0.5}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":830,"y":860,"wires":[["ca308724.f192c8"]]},{"id":"ca308724.f192c8","type":"random","z":"ebbc7cb3.0c2d5","name":"random","low":"1","high":"4","inte":"true","property":"random_number","x":980,"y":860,"wires":[["ef9b8544.ec7098"]]},{"id":"ef9b8544.ec7098","type":"change","z":"ebbc7cb3.0c2d5","name":"change","rules":[{"t":"change","p":"random_number","pt":"msg","from":"1","fromt":"num","to":"Alarm! Alarm! wie pakt er lekkers uit de la?","tot":"str"},{"t":"change","p":"random_number","pt":"msg","from":"2","fromt":"num","to":"Hej boefje! Wat doe jij daar? ","tot":"str"},{"t":"change","p":"random_number","pt":"msg","from":"3","fromt":"num","to":"Waarschuwing! De snoepla is geopent!","tot":"str"},{"t":"change","p":"random_number","pt":"msg","from":"4","fromt":"num","to":"Stop! Lekkers pakken uit de la, weet je het zeker?","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":860,"wires":[["2946e41a.b2a23c"]]},{"id":"2946e41a.b2a23c","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"play prompt","server":"779066dc.805a78","version":1,"debugenabled":true,"service_domain":"tts","service":"google_say","entityId":"media_player.keuken","data":"{\"message\":\"{{random_number}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":920,"wires":[["e80fb4f4.70b038"]]},{"id":"e80fb4f4.70b038","type":"delay","z":"ebbc7cb3.0c2d5","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":820,"y":920,"wires":[["e60f2bb0.caa5f8"]]},{"id":"e60f2bb0.caa5f8","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"restore","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"sonos","service":"restore","entityId":"media_player.keuken","data":"{\"with_group\":\"true\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":920,"wires":[["9868672d.399638"]]},{"id":"9868672d.399638","type":"api-call-service","z":"ebbc7cb3.0c2d5","name":"unpause","server":"779066dc.805a78","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_play","entityId":"media_player.keuken","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1100,"y":920,"wires":[[]]},{"id":"779066dc.805a78","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]