Greetings All,
I’m reaching out to get help with my first script. I have spent days trying to put this together and have had some degree of success/luck but I've become hopelessly stuck! Any help would be greatly appreciated!
What I am trying to put together is a script that does the following:
1. Set computer volume (not iTunes volume) to value of a variable.
2. If iTunes is running pause it.
3. Set computer volume to a particular value of a variable.
4. Pause iTunes if running.
5. Make an announcement of that device using it’s device name each time that device is opened.
6. Wait for the announcement to complete.
7. Return computer volume back to the value of a variable.
I have been successful with steps 1-5, but can't figure out how to have the script wait for the announcement to finish before returning the volume back to the a value that is assigned to a variable (step 7).
Please help!!
currentVol = indigo.variables[747606079].value # current volume of Mac
currentVol = str(currentVol)
previousVol = indigo.variables[181323221].value # previous volume of Mac
previousVol = str(previousVol)
indigo.variable.updateValue(181323221, currVol) # replace value of previousVolume with current volume.
itunesId = "com.perceptiveautomation.indigoplugin.itunes"
itunesPlugin = indigo.server.getPlugin(itunesId)
if itunesPlugin.isEnabled():
speakValue = indigo.variables[102235652].value # here I'd like for the speaking to finish before moving to next step
currentVolume = indigo.variables[747606079].value
from subprocess import call # change of Mac volume
call(["osascript -e 'set volume output volume 55'"], shell=True) # here i'd like to replace the "55" with the value of a variable
itunesPlugin.executeAction("pauseAndSay", deviceId=180651512, props={'message':speakValue})
prevVol = indigo.variables[181323221].value
prevVol = str(prevVol)
indigo.variable.updateValue (747606079, prevVol)