Restore previous Input State

colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Restore previous Input State

Post by colinpartridge »

I'm trying to achieve the following..with my Onkyo NR-tx616. The idea is to switch inputs to an airplay receiver to play an audio file and then return to existing input and level.

1.Store input and volume
2.Change input and volume
3.play audio file
4.Restore original input and volume

1, 2 and 3 are easy enough, but I'm struggling with number 4.
Is this possible with the Onkyo receiver plugin or will I have to go down the cynical network plugin route.

Any help or ideas appreciated.

Colin
User avatar
DaveL17
Posts: 7321
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Restore previous Input State

Post by DaveL17 »

I think that this could be done fairly easily with a linked script, but there may be a simpler way to do it directly through Indigo.

But first it would help to have a bit more information on how you're invoking the process. For example, are you doing it with an Action Group?
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

Hi Dave
I have two triggers which track the changes of Input and Volume, stored as variables, The idea is that using an action group the input and volume is changed, then the audio file is played and the Reciever is then returned to its original state.

Colin
User avatar
DaveL17
Posts: 7321
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Restore previous Input State

Post by DaveL17 »

Okay, let's see if I have it.

1. At the outset, the receiver may be in any state (some source, some volume.)
2. You routinely store the source and volume into variables (let's call this State 1.)
3. You want to set the source and volume to a predetermined level (let's call this State 2.)
4. You want to play an audio file at State 2.
5. You want to return the receiver to State 1.

Is that right? Do you assume that the receiver is on when you call the Action Group?
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

Exactly that Dave, the action group is triggered either by the receiver being turned on, or a particular "state" being enabled. The cheesy idea is to have a piece of music playing whilst a projector screen is being lowered.

Colin
User avatar
DaveL17
Posts: 7321
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Restore previous Input State

Post by DaveL17 »

Got it. You should be able to do this with a Python script, but it depends a bit on how Adam has implemented the plugin. I think we'll need Adam or someone that's familiar with the Onkyo plugin to chime in at this point.

Here's how we'd set the volume to the value of a variable using the iTunes plugin (which will surely have a somewhat different implementation.) Maybe it will be enough to get you started.

Code: Select all

target_volume = indigo.variables[12345678].value
itunesId      = "com.perceptiveautomation.indigoplugin.itunes"
itunesPlugin  = indigo.server.getPlugin(itunesId)

if itunesPlugin.isEnabled():
	itunesPlugin.executeAction("setVolume", deviceId=123456789, props={'volume':target_volume})
Cheers,
Dave
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

Thanks for your input Dave. I hadn't considered this approach, which certainly looks more elegant.

Colin
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Restore previous Input State

Post by RogueProeliator »

Yes, I would go Dave's route - you can easily set the input and volume via a Python script in order to utilize the variable value that you stored. Any defined action in Indigo plugins can be executed via Python (or should be, perhaps I shouldn't be so absolute!) For the Onkyo input and volume is should be something like (stealing Dave's example and making it w/ the plugin values here):

Code: Select all

target_inputNum = indigo.variables[12345678].value 
target_volume = indigo.variables[23456789].value
pluginId      = "com.duncanware.onkyoNetworkRemote"
onkyoPlugin  = indigo.server.getPlugin(pluginId)

if onkyoPlugin.isEnabled():
   onkyoPlugin.executeAction("setCurrentInput", deviceId=123456789, props={'zone':'main','inputNumber':target_inputNum})
   onkyoPlugin.executeAction("setVolumeLevel", deviceId=123456789, props={'zone':'main','volumeLevel':target_volume})
I didn't test this but was just changing the values in Dave's example, so I think it should work. If you give it a try and it doesn't, post the error and we can work through it.

Adam
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

Thanks Adam and Dave, I'll give this a whirl when I get some quiet time to check it out,

Colin
User avatar
DaveL17
Posts: 7321
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Restore previous Input State

Post by DaveL17 »

RogueProeliator wrote:Yes, I would go Dave's route
RogueProeliator wrote:(stealing Dave's example and making it w/ the plugin values here)
While I appreciate the shout out, the example is from the wiki. :)
http://wiki.indigodomo.com/doku.php?id=plugins:itunes

Dave
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

Had time to make this work this morning. What I tried to do was all the steps within one external python script, this didn't quite work as expected as the temp variables weren't being updated within the script. Once I had separated out the restore input state script all worked as required. I just need to get the timing now.

Cheers

Colin
hamw
Posts: 1342
Joined: Mon Mar 31, 2008 7:45 pm

Re: Restore previous Input State

Post by hamw »

Colin,

Just got an Onkyo receiver to serve as my net and radio inputs for my WHA setup. Could you post your script? I might want to use something like that as well.

Thanks!
colinpartridge
Posts: 377
Joined: Mon Jan 13, 2014 10:28 am
Location: London, UK

Re: Restore previous Input State

Post by colinpartridge »

hamw wrote:Colin,

Just got an Onkyo receiver to serve as my net and radio inputs for my WHA setup. Could you post your script? I might want to use something like that as well.

Thanks!
The restore previous state bit is follows. relies on three Tempvariables which are set by another script...values picked up from the current receiver state.
OnkyoTempInputState
OnkyoTempVolumeState
OnkyoTempListenMode

Code as follows.

Code: Select all

OnkyoTempInputState = indigo.variables[1584032125].value # "OnkyoTempInputState"
OnkyoTempVolumeState = indigo.variables[893869541].value # "OnkyoTempVolumeState"
OnkyoTempListenMode = indigo.variables[802129718].value # "OnkyoTempListenMode"
OnkyopluginId      = "com.duncanware.onkyoNetworkRemote"
onkyoPlugin  = indigo.server.getPlugin(OnkyopluginId)

#restore original settings
if onkyoPlugin.isEnabled():
   onkyoPlugin.executeAction("setCurrentInput", deviceId=260665161, props={'zone':'main','inputNumber':OnkyoTempInputState})
   onkyoPlugin.executeAction("setVolumeLevel", deviceId=260665161, props={'zone':'main','volumeLevel':OnkyoTempVolumeState})
   onkyoPlugin.executeAction("setListeningMode", deviceId=260665161, props={'zone':'main','listeningMode': OnkyoTempListenMode})
Hope it makes sense. Obviously you would have to replace the variable ids with your own.

Colin
Post Reply

Return to “Onkyo Receiver”