[SOLVED] Can you save and set back volume?

I have a welcome home message I have my Sonos say when certain individuals come home (presence).

What I’m trying to do. Let’s say the volume is set to 3 but when i send notices out, want to set it up to 5, and then back to it’s previous value of in the example 3.

Is this possible?

Thanks.

JR

See this post for alexa. You should be able to do something similar with the sonos using storeState and restoreState.

Do you have an item for the volume?

var Number savedVolume = VolumeItem.state as Number
VolumeItem.sendCommand(5)
say("Say hello to my little friend!!")
createTimer.now.plusSeconds((5), [ |
    VolumeItem.sendCommand(savedVolume)
])

Accordning to my experience with Sonos and the say command, the utilization of that command uses the “NotificationVolume” of the box you are sending the the command to. Each stream which is actually playing is stopped, the NotifciationVoume is set, the text is “said” and after the max time of (I guess) 20 seconds the original stream is resumed with its original (unchanged!) volume.

In other words, do nothing, it is working like you want it! Or better, send a big Thanks! to the developer (@Lolodomo)

Thank you both. For reference I have an item:

Dimmer SonosOneFamilyRoom_Volume “Volume” {channel=“sonos:One:RINCON_XXXXXXXXXXXXXX:volume”}

Vincent, with what Jürgen said and not knowing if it’s setting the volume where I want it to, I think it says the phrase at the current volume, how would you put my item into your example?

Thanks.

JR

Replace volumeItem with SonosOneFamilyRoom_Volume

Thanks. I’m guessing even though I tell Alexa on my Sonos One to set a volume of 5, in the GUI it’s 50 so thinking I should set it to 50 not 5.

Thanks.

JR

Yep, Also adjust the timer length to how long it takes to say the sentence

If you set the logging to DEBUG for the So so binding, you will see what is set for volume and when.

The logs are showing an error after the comma. Says mismatched input ‘,’ expecting end

JR

Think I figured it out. The period after createTimer should have been an open “(”

JR

1 Like

Yes sorry, corrected above