help with scripting volume control [SOLVED]

Posted on
Wed Feb 09, 2022 10:29 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

help with scripting volume control [SOLVED]

hi jon, can you help me with syntax for this when you get a chance.. :D or.. is it even possible? i'm trying to set a state.. may be barking up the wrong tree.

anyway, thanks!


Code: Select all
tempVOL = indigo.variables[567100085].value # "roonMastrBedVOL"


pluginID = "com.autologplugin.indigoplugin.rooncontroller"
roonPlugin = indigo.server.getPlugin(pluginID)
if roonPlugin.isEnabled():
   roonPlugin.executeAction("setVolume", deviceId=81926484, state={'volume_value': tempVOL})
Last edited by dtich on Thu Feb 10, 2022 11:35 am, edited 1 time in total.

Posted on
Thu Feb 10, 2022 7:04 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: help with scripting volume control

Try this:
Code: Select all
tempVOL = int(indigo.variables[567100085].value) # "roonMastrBedVOL"
roonId = "com.autologplugin.indigoplugin.rooncontroller"
roonPlugin = indigo.server.getPlugin(roonId)
roonOutputDevId = 81926484  # Note: The Roon output NOT zone
if roonPlugin.isEnabled():
    roonPlugin.executeAction("setVolume", deviceId=roonOutputDevId, props={"volumePercentage": tempVOL})
I tested the equivalent on my system and it worked OK. :)

Posted on
Thu Feb 10, 2022 9:56 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: help with scripting volume control

thanks jon, helpful.

my issue with using percentage is i don't have access to the percentage directly - i can only see the volume_value which is the relative display value factoring in the volume leveling necessary for the output device i'm using. sooo..

can i set the volume_value? and assuming not.. what is the formula used to arrive at volume_value from percentage? i'm trying to work it out.. after some coffee i'm sure it'll start to click, lol.

basically 100% = 0, 90% = -8, 63% = -30, 50% = -40, 30% = -56, 5% = -76, 0% = -80 (hard limit)... that's the scale. i'm fuzzy how to work that out into a formula.. can't see another way to accomplish this though.

so.. if i take the abs value of the vol-value, multiply by 1.25 (the 0-80 scale) then subtract that from 100... does that give me the percentage??? lol. coffee. needed.

-56 = 56 x 1.25 = 70 ; (100-70) = 30%. ???

is this the cleanest solution to this issue? :D



thanks a lot!

Posted on
Thu Feb 10, 2022 10:09 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: help with scripting volume control

Your maths seems better than mine. :wink:

It occurs to me that I might have just been assuming it is a percentage, while it actually might be whatever units you are using.

I suggest that you don't have Roon playing through that output to avoid getting deafened and try the script and then look at what Roon sets the volume to. Is it a percentage or absolute value? You should be able to determine that?

Posted on
Thu Feb 10, 2022 10:18 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: help with scripting volume control

Code: Select all
tempVOLdisp = int(indigo.variables[567100085].value) # "roonMastrBedVOL"
tempVOL = (100 - (abs(tempVOLdisp) * 1.25)

roonId = "com.autologplugin.indigoplugin.rooncontroller"
roonPlugin = indigo.server.getPlugin(roonId)
roonOutputDevId = 81926484  # Note: The Roon output NOT zone

if roonPlugin.isEnabled():
    roonPlugin.executeAction("setVolume", deviceId=roonOutputDevId, props={"volumePercentage": tempVOL})


seems right but is throwing syntax err on the 'roonId =' line... ?

or, does it not like my variable inits at the top, is that throwing it off, as the roonId used to work just fine..


thx!

Posted on
Thu Feb 10, 2022 10:23 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: help with scripting volume control

The error is because you're missing a ")" on the line before.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Feb 10, 2022 10:29 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: help with scripting volume control

autolog wrote:
Your maths seems better than mine. :wink:

It occurs to me that I might have just been assuming it is a percentage, while it actually might be whatever units you are using.

I suggest that you don't have Roon playing through that output to avoid getting deafened and try the script and then look at what Roon sets the volume to. Is it a percentage or absolute value? You should be able to determine that?


no, you are correct, it is a percentage as used.. i think my formula is right and this (above) should work pretty well, but it's tripping on something stupid.. can't figure out what it's problem is as the lines used to be fine. why would changing the var calculation suddenly make it not like the plugin name? coffee....

Posted on
Thu Feb 10, 2022 10:30 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: help with scripting volume control

FlyingDiver wrote:
The error is because you're missing a ")" on the line before.


......If I keep blaming lack of coffee does that absolve me?


Thank you Joe!

This (now) works well. Thanks all.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests