Built-in variables

Posted on
Sun Oct 29, 2017 7:09 pm
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Built-in variables

Can't believe this hasn't been asked and answered numerous times, but I am looking for a list of built-in system variables. For example, I have scripts that use the same code, but they act on different devices depending on which control page they are called from. So, for example, a script to change a DirecTV channel works on a different DirectTV receiver depending on which control page it's called from. Rather than explicitly set a variable for the page, I know each page has a name, and want to automatically set the value of the page from the name of the control page from which the change channel button is pressed.

Is there a list of built-in variable names, like control page name, and how do I access them?

If not, wouldn't this seem to be something Indigo should support? It makes no sense to hard code this for every control on a control page; I should be able to retrieve the page name and use it in my scripts.

Thanks

Posted on
Sun Oct 29, 2017 9:02 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Built-in variables

There are no such variables. I've added it to the feature request list.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Oct 29, 2017 9:14 pm
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

So is there no way to know, for example, what page I'm on?

Is there any way to have a page automatically set a variable when it is opened?

Posted on
Mon Oct 30, 2017 5:18 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Built-in variables

kennybroh wrote:
So is there no way to know, for example, what page I'm on?

Is there any way to have a page automatically set a variable when it is opened?


How are you going to handle multiple users opening different control pages at (more or less) the same time? Trying to do a system-wide "current" control page is asking for trouble, IMHO.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 30, 2017 6:30 am
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

I understand that issue entirely. In my system there is rarely more than one person utilizing it at a time. Nevertheless, if this were implemented correctly, the occurrence of the variable would be sent each time a control is activated, so each user would be sending the variable discretely.

Also, in many programming languages there are distinctions between local and global variables. So I would expect properly implemented, this could be a local variable peculiar to the particular device on which the page is open.

Independent of the wisdom of doing this, however, is there no way to set a variable automatically when a page is opened?

Posted on
Mon Oct 30, 2017 6:46 am
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

But the way I was hoping to do this wouldn't involve a global variable. If I had access to the control page name or ID, I could simply pass it as a parameter in a script, and have the script take appropriate action based on that value. That way I'd never have to set a variable at all.

Posted on
Mon Oct 30, 2017 7:39 am
bkmar1192 offline
Posts: 274
Joined: Sep 12, 2015

Re: Built-in variables

In the button that changes to the other page - add a server action that sets a variable equal to the page name.


Sent from my iPhone using Tapatalk

Posted on
Mon Oct 30, 2017 8:13 am
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

That won’t work. In a multi-user environment if you are already on the page you aren’t switching to it, but as FlyingDiver points out, if another user is on a different page the variable will be different.

What I’m really looking for is the ability to know what page you are on when a control is clicked.

Posted on
Mon Oct 30, 2017 8:15 am
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

BTW, I’ve been doing what you suggested and it’s fine as long as only one person is using the system at a time. It breaks down when more than one person uses it in more than 1 room.

Posted on
Mon Oct 30, 2017 8:36 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Built-in variables

I'm still trying to get my head around exactly how you want to use this information. You say you have scripts that you activate based on buttons on a control page. Those scripts are in Action Groups? And you want those scripts to do different things depending on what control page calls that script. Right? So your idea is to somehow make the identity of the calling page available to the script? This is pretty much the same as wanting to know how an Action Group was called in general. Was it an Event Trigger? A Schedule? Or a Control Page button? All the same. And no, I don't think there's anything currently in Indigo that does that.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 30, 2017 10:53 am
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

Yes, that's the idea. For instance, I have 6 or 7 DirecTV boxes, most of which are connected to Onkyo receivers. I also have Sonos and AppleTVs in those rooms, hooked up to the Onkyos. I have control pages for each room, because the lighting, hvac and relevant action groups differ dependnig on where you are.

So, for example, when I press Guide, I call a python script that checks the variable for the room you are in--which is presently set only by the button that selects the page--and on that basis knows which DirecTV box to pass the command to. I don't want to have hard coded actions on each page because, for instance, even though I use static IPs when I can, sometimes the addresses of the devices change and it is a nightmare to update the pages when something like that happens. This way the scripts look at variables which hold the IP address for each box.

But as you correctly point out, where multiple devices are used--whether by multiple people one--the variable for the room can get out of synch. Hence the desire to be able to have an internal variable pass the control page, or even control, ID. As you also observed, that could be extremely useful for many purposes.

In other high level languages I've used, the GUI has "embed points", which I badly miss in Indigo, where you can insert scripts to be processed before and /or after the control event itself. For example, in additon to what Indigo now does--having a control call a client and/or server event of some sort,--you could also add events before or after what the control itself calls. So in this context, my "Guide" control could set the page name, and then call the action group. The same concept would apply to the page itself--you could have an event process before the page opens, and on exit from the page.

Which brings something to mind I just thought of . If a control calls both client-side and server-side event, does the client-side execute first? If so, I could accomplish some of what I'd like to do that way.

Posted on
Mon Oct 30, 2017 2:25 pm
bkmar1192 offline
Posts: 274
Joined: Sep 12, 2015

Re: Built-in variables

I like the idea of pre and post processing on a control page. However, working within the current structure, could you set the room variable on each button press versus page load.

For example: When the play button in the living room is pressed it sets the room variable to “living room” and then executes the play action. If the pause button is pressed in the kitchen the room variable is set to kitchen and the pause action runs.




Sent from my iPhone using Tapatalk

Posted on
Mon Oct 30, 2017 4:25 pm
kennybroh offline
Posts: 531
Joined: Dec 13, 2009
Location: Baltimore

Re: Built-in variables

My initial reaction to what you were suggesting was it would have required me to basically create a separate script for each control to set the page, set the key I wanted pressed, and to call the function to send that key to the proper box. But I noticed something the other day, and after probing a little deeper, I realized for the first time (DUH) I can do multiple things on a control I never realized I could do. For some reason I never noticed that you can call a series of events, not just one.

So this actually greatly simplifies how I handle controlling similar devices in different rooms and pretty much eliminates the multi-user problem.

Aside from only setting the room variable when someone selected a control page, what I had done until now was have multiple similar scripts for each function for the device, say Guide, Fast Forward, etc., which would check the room variable and send the command to the right place. But as we have been discussing, if the room variable was out of sync it sent the command somewhere else.

Now, I only need 1 script for all of the DirectTV functions. Before that script is called, I set the room variable AND a variable for the DirecTV key to press. Then I call a single script that gets the room, the DirecTV box address, and the key to press, and executes the function. Wish I realized .a control could call a series of server events before....

So, now I understand I can do pre- and post- processing for any control, but not the page itself, which would still be useful for other purposes.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests