Saving and Restoring Airfoil Speaker Volume Settings

Posted on
Thu Aug 15, 2019 7:40 pm
mgolden50 offline
User avatar
Posts: 176
Joined: Jan 29, 2007
Location: Chandler, AZ

Saving and Restoring Airfoil Speaker Volume Settings

I found my self frustrated that Rogue Amoeba didn't seem to provide a native way within their UI or API to save and restore speaker volume settings unlike their capability for saving connection settings. Because it's not in their API, it seems not to be in the otherwise excellent Airfoil Plugin. So as a reluctant Indigo Python newbie I offer a framework for a set of Indigo Actions which save each speaker's volume setting to an associated variable for each speaker; and a script which reads the volume settings from those variables and and sets the associated speaker volumes to those settings using Airfoil Plugin. I know I should probably do this with single variable holding a list of speaker IDs and volume settings but that will have to wait for my further Python skill development.

To save the speaker volume levels I use a list of "Insert Device State" actions under a master action group and set the state for each variable insertion action to "volume" into the variable I created for each speaker.

I then created the script below to retrieve the settings from those variables and use them to set the Airfoil speaker volumes via the Airfoil Plugin
-------------------------
## Set Speaker Volumes To Saved Variable Values
## First Set local Pythons Variables to Indigo's Variables For The Saved Speaker Levels

PatioLevel = (indigo.variables[1946413755]).value
OfficeLevel = indigo.variables[1794284846].value
LivingRoomAnnounceLevel = indigo.variables[353659073].value
LivingRoomLevel = indigo.variables[1157709881].value
KitchenLevel = indigo.variables[1080959149].value
GuestRoomLevel = indigo.variables[602238934].value
GuestBathRoomLevel = indigo.variables[601851318].value
FrontDoorLevel = indigo.variables[1457974229].value
AlexaCmdLevel = indigo.variables[442253647].value

## Then set the Airfoil speaker levels to the values saved in the Indigo Variables using Airfoil Plugin
airfoilPlugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.airfoilpro")

result = airfoilPlugin.executeAction('setVolume', deviceId= 1419144848, props={'volume': (PatioLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 1089930288, props={'volume': (OfficeLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 970630868, props={'volume': (LivingRoomAnnounceLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 1564935420, props={'volume': (LivingRoomLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 1824678982, props={'volume': (KitchenLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 1039605571, props={'volume': (GuestRoomLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 127530933, props={'volume': (GuestBathRoomLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 1263104441, props={'volume': (FrontDoorLevel)}, waitUntilDone=True) # ID of this Speaker
result = airfoilPlugin.executeAction('setVolume', deviceId= 657190684, props={'volume': (AlexaCmdLevel)}, waitUntilDone=True) # ID of this Speaker
-----------------------
There are likely much more efficient ways to implement this code. But it works... and hey, I'm just getting started.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest