Page 1 of 1

help with scripting volume control [SOLVED]

PostPosted: Wed Feb 09, 2022 10:29 pm
by dtich
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})

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 7:04 am
by autolog
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. :)

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 9:56 am
by dtich
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!

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 10:09 am
by autolog
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?

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 10:18 am
by dtich
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!

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 10:23 am
by FlyingDiver
The error is because you're missing a ")" on the line before.

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 10:29 am
by dtich
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....

Re: help with scripting volume control

PostPosted: Thu Feb 10, 2022 10:30 am
by dtich
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.