Page 1 of 1

Variable substitution of Sonos Volume action

PostPosted: Sat Aug 12, 2017 4:34 am
by elov
Hi,

I modified the current version in my setup to allow for dynamic Volume editing (temporary decrease volume and restore on a doorbell or front door entry).

I edited the this part of sonos.py adding eval(self.plugin.substitute( and the new_volume < 0 condition.
Now I store my current Sonos player volume as variables and have Sonos Volume Actions that make calculations to decrease the current volume and then restore it after a set time.

I hope you can add this permanently. :)

Code: Select all
      elif action == "Volume":
         self.plugin.debugLog("Sonos Action: Volume")
         current_volume = dev.states["ZP_VOLUME"]
         new_volume = eval(self.plugin.substitute(pluginAction.props.get("setting")))
         if new_volume < 0:
            new_volume = 0
         self.SOAPSend (zoneIP, "/MediaRenderer", "/RenderingControl", "SetVolume", "<Channel>Master</Channel><DesiredVolume>"+str(new_volume)+"</DesiredVolume>")
         indigo.server.log(u"ZonePlayer: %s, Current Volume: %s, New Volume: %s" % (dev.name, current_volume, new_volume))

Re: Variable substitution of Sonos Volume action

PostPosted: Thu Aug 22, 2019 12:03 pm
by elov
I'd like to bump this request Nick.

I've been manually modifying this line once you release an update for the last 2 years. Would be great if you could add this functionality in your releases.

Re: Variable substitution of Sonos Volume action

PostPosted: Sat Mar 28, 2020 9:29 am
by nlagaros
This will be in the next release.

Re: Variable substitution of Sonos Volume action

PostPosted: Sun May 03, 2020 10:11 am
by wideglidejrp
I see in the release notes that v1.0.17 includes "Variable substitution for Volume and Group Volume actions.". What does that mean? How do you use this functionality? I do not see anything new in the plugin actions menu.

Re: Variable substitution of Sonos Volume action

PostPosted: Mon May 04, 2020 9:01 am
by jay (support)

Re: Variable substitution of Sonos Volume action

PostPosted: Mon May 04, 2020 11:16 am
by wideglidejrp
Does this mean instead of entering a value for a zone player volume, I can enter %%v:living_room_volume%% assuming that variable has a value between 0 and 100?

Re: Variable substitution of Sonos Volume action

PostPosted: Tue May 05, 2020 8:11 am
by jay (support)
I don't know since I don't use the plugin, but why don't you try it and see? And, it should be the ID of the variable, not the name...

Re: Variable substitution of Sonos Volume action

PostPosted: Tue May 05, 2020 8:24 am
by wideglidejrp
Ok, now I get it. Thanks. I had tried it before asking the question, but using name instead of ID. I should have known better because I am using Python scripts to control thermostats. I tried again with the ID and it works perfectly. This is a really great addition to the functionality of the Sonos plugin. I will establish a variable for each Sonos player. I can think of many uses. There are probably other variables which could be useful. What I am understanding is that Indigo has enabled this ability and it can work for any variable if the plugin developer enables it. Thanks.