(Sonos) NotificationVolume after Restart

I’m using the NotificationVolume of my Sonos boxes to set the volume for “say” commands. That works great!
I’m using a rule which checks wether the NotificationVolume matches my desired value, if not it is set to my value. That is working graet also,however after each restart of OH the NotificationVolume is set to the (Main)Volume. Why is that?
I have the channels for the NotificationVolume declared on my system. After a restart I check the value of that channel, it matches my desired setting, however it will be set to the (Master)Volume setting. Doing that for a consecutive time my desired value will be used.
Does this behaviour have a reason?

I agree the behaviour is strange.
The binding has no way to know at startup what was the previous value (as it is only stored in an item) so it sets it to null at startup and when it needs it it sets it to the current volume.
It could make sense to store it in a thing configuration setting rather than a channel to persist the value. But doing that you could not change the value without updating your thing. It could not be done through a rule. Not ideal.
Even if you persist your item, the item value will be restored at startup but the binding will not be informed about this value.
Thinking about it, I see no real solution !

Thanks for the answer!

I do understand why the notification volume is set to the volume initially, however I’m checking the value of all those volume settings (in that instance it is probably set to the mainvolume) , if that check doesn’t equal my desired setting it should be altered. But that is only working on the second run. ???
Even when changing the notification volume manually via PaperUI-Control that behaviour remains.

However I can live with that! Just remember the use the rule once for each box, then it runs as desired.

Thanks.

I am not sure to understand ehat you mean by “second run” but normally if you set your channel using UI or a rule before your first sound notification and your thing is ONLINE, the notification volume should be set with your value and then used when you notify a sound.

OK, I’ll try it in other words:

I do restart OH2, after that the Items for controlling the Volumes and NotificationVolumes of my Sonos Boxes are showing “4” for the Volume and “20” for the NotificationVolume.

Then I do run my rule once:

Rule:

val Number NotificationVolume = 20

rule “SagEtwas”

when
Item SayCommand received update //String Item holding the text
then
var string AudioSink
switch AudioSink {
case Lautsprecher.state.toString==“Küche” : AudioSink=“sonos:PLAY1:RINCON_xx1400”
case Lautsprecher.state.toString==“Wohnzimmer” : AudioSink=“sonos:PLAY1:RINCON_yy1400”
case Lautsprecher.state.toString==“Gästezimmer” : AudioSink= “sonos:PLAY1:RINCON_zz1400”
default:AudioSink=“sonos:PLAY1:RINCON_xx1400”
}
gPlayer_NotificationVolume.allMembers.filter(s | s.state!=NotificationVolume ).forEach [item | item.sendCommand(NotificationVolume)]
say(SayCommand.state.toString,“voicerss:deDE”,AudioSink)
logInfo(“SayCommand”,“Es ist alles gesagt!”)
end

The log shows:

14:23:19.259 [INFO ] [marthome.event.ItemStateChangedEvent] - SayCommand changed from to Hallo
14:23:20.048 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PLAY to PAUSE
14:23:20.071 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PLAY to PAUSE
14:23:20.085 [INFO ] [ome.event.GroupItemStateChangedEvent] - gPlayer_NotificationVolume changed from 20 to UNDEF through PlayWZ_L_NotificationVolume
14:23:20.086 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_NotificationVolume changed from 20 to 4
14:23:20.823 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PAUSE to PLAY
14:23:20.860 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PAUSE to PLAY
14:23:22.239 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PLAY to PAUSE
14:23:22.258 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PLAY to PAUSE
14:23:25.805 [INFO ] [se.smarthome.model.script.SayCommand] - Es ist alles gesagt!

Why is the NotificationVolume changing from 20 to 4?

When running the rule once more I get the following:

14:23:58.111 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘SayCommand’ received command Hallo
14:23:58.180 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘PlayWZ_L_NotificationVolume’ received command 20
14:23:58.184 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_NotificationVolume changed from 4 to 20
14:23:58.202 [INFO ] [ome.event.GroupItemStateChangedEvent] - gPlayer_NotificationVolume changed from UNDEF to 20 through PlayWZ_L_NotificationVolume
14:23:58.625 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PLAY to PAUSE
14:23:58.654 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PLAY to PAUSE
14:23:59.171 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Volume changed from 4 to 20
14:23:59.187 [INFO ] [rthome.model.script.MaxVolumeChecker] - MaxVolume =25
14:23:59.259 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PAUSE to PLAY
14:23:59.290 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PAUSE to PLAY
14:24:00.784 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PLAY to PAUSE
14:24:00.814 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayKueche_Controller changed from PLAY to PAUSE
14:24:03.394 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Volume changed from 20 to 4
14:24:03.411 [INFO ] [rthome.model.script.MaxVolumeChecker] - MaxVolume =25
14:24:04.208 [INFO ] [marthome.event.ItemStateChangedEvent] - PlayWZ_L_Controller changed from PAUSE to PLAY
14:24:04.237 [INFO ] [se.smarthome.model.script.SayCommand] - Es ist alles gesagt!

Now the desired volume(20) is set for the notification!

Note: PlayKueche was grouped to PlayWZ_L, and MaxVolumeChecker is another rule the is called whenever the volume is changed.

Your rule is not basic !
Maybe you should try first with a basic rule and only one Sonos.
An advice could be to consider a delay between the change of volume and the say command. If not, maybe your say command is finally run before the notification volumes are set.

Will try that and report!

I went into the other direction and made a rule that sets the NotificationVolume for all Boxes at system start. That is working!
Thanks for your help and “Guten Rutsch” (i.e. Have a nice start into the new year!)

That was a better approach I think.

Can you please posthow you did

My Rule:

val Number Notificationvolume= 20

rule "InitialNotificationVolumeSetting"

when
     System started
then
    gSonosPlayers_NotificationVolume.allMembers.forEach[item | item.sendCommand(NotificationVolume)]
    logInfo("InitialNotificationVolumeSetting", "NotificationVolume set!")
end 

Note:
The first line (“val …”) has to be above each rule in thev file you are using!
All Sonos-Player have to be members ofn the Group “gSonosPlayers”!

Today I stumbled over this topic after I observed the behavior in my environment as well and looking for a solution. Should we add a note to the documentation that neither Sonos nor the binding stores the notification sound volume and the user has to take care of it on its own?

Sounds like a good suggestion which I could or should have madd myself.

[Edit]
Not to forget, Happy New Year!

Happy New Year, Jürgen.

Do you’re going to prepare a PR? Don’t you?

I can do that, give a bit of time, because I have to read the actual ReadMe first.

[Edit] Done!

Thank you.

I submitted a proposal for storing the notification sound volume in the binding.

@cweitkamp I like it, and I think a similar approach would work nicely with the Squeezebox binding, too. :wink:

Cool, please go to the issue and vote for it. :wink: