Restore previous Input State

Posted on
Sat Dec 26, 2015 4:32 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Restore previous Input State

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

Posted on
Sat Dec 26, 2015 5:50 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Restore previous Input State

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] - [My Forums]

Posted on
Sat Dec 26, 2015 6:44 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Posted on
Sat Dec 26, 2015 6:58 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Restore previous Input State

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] - [My Forums]

Posted on
Sat Dec 26, 2015 7:36 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Posted on
Sat Dec 26, 2015 8:05 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Restore previous Input State

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] - [My Forums]

Posted on
Sat Dec 26, 2015 9:44 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Colin

Posted on
Sun Dec 27, 2015 10:36 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Restore previous Input State

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

Posted on
Mon Dec 28, 2015 1:14 pm
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Colin

Posted on
Mon Dec 28, 2015 2:27 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Restore previous Input State

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] - [My Forums]

Posted on
Wed Dec 30, 2015 5:54 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Posted on
Fri Apr 08, 2016 5:52 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Restore previous Input State

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!

Posted on
Sat Apr 09, 2016 9:34 am
colinpartridge offline
Posts: 373
Joined: Jan 13, 2014
Location: London, UK

Re: Restore previous Input State

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

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests