Group based on variables

Posted on
Sun Nov 15, 2015 7:09 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Group based on variables

I have a few dozen variables that I would like to drive a status of another variable. Is there some simple method for doing this because what I have right now is extremely convoluted.

All I was is something that says on if any of the variable are true and off if all of the variable are false. Real time status would be ideal.

Posted on
Mon Nov 16, 2015 12:23 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Group based on variables

Two options I can think of off the top of my head: you can create a "has any change" trigger for each variable in the group that calls a script - the script would do the work to figure out whether the group is on/off and then set the state variable appropriately. This is the less technical option.

The other option would be to create a plugin to do it. More general, but more technical skill required.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 16, 2015 1:15 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Group based on variables

I have a few dozen variables that I would like to drive a status of another variable. Is there some simple method for doing this because what I have right now is extremely convoluted.

I would create an action group that is, as Jay suggested, a single (embedded) script that basically checks each variable's value and sets the target variable appropriately. Then your triggers for each variable are "On Any Change" to call the said Action Group; easy and simple to set each trigger though of course it creates a bunch of them nearly identical. But this way if you add/remove variables later you need only modify the single script instance.

Adam

Posted on
Tue Nov 17, 2015 1:07 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Group based on variables

The ideal way, that isn't available yet, would be for Matt/Jay to extend the Virtual Device plugin to support Variables.

That allows exactly your scenario - if any selected device is On, then this Virtual Device is On. But it doesn't work for Variables.

Depending on how your Variables are used, you could swap them for either a Virtual On/Off device or even an X10 device (without the interface) - that allows you to maintain On/Off state just like the Variables, but also allows you to use the Virtual Device to determine if any device is On.


Sent from my iPhone using Tapatalk

Posted on
Tue Nov 17, 2015 8:59 pm
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Group based on variables

right now I am using 3 triggers with a whole pile of conditionals for the variables... up to 32.

1 to trigger when any of them comes on, one to trigger if one of them goes off and any others are still on and another to trigger when they are all off.

This initially wasn't supposed to have that many variables, but it has grown to be a pain in the ass and I was hoping to get something a little less maintenance intensive.

Some good ideas that I'll have to put some thought into... it works for the most part now so I'm a little reluctant to "fix" it, but like I said, it is getting more maintenance heavy than I would like.

Posted on
Tue Nov 17, 2015 10:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Group based on variables

howartp wrote:
The ideal way, that isn't available yet, would be for Matt/Jay to extend the Virtual Device plugin to support Variables.

That allows exactly your scenario - if any selected device is On, then this Virtual Device is On. But it doesn't work for Variables.


Your talking about a Device Group device - which as the name implies, doesn't support variables. Adding them I think would over complicate that device type. My second suggestion, create a plugin, would somewhat mimic what a Device Group does except for variables (a Variable Group device)? The logic is a bit stranger due to the fact that a variable can contain basically any string value.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 17, 2015 10:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Group based on variables

Dewster35 wrote:
Some good ideas that I'll have to put some thought into... it works for the most part now so I'm a little reluctant to "fix" it, but like I said, it is getting more maintenance heavy than I would like.


If you take the script approach I outlined above, you could even make the script smart enough to look for variables in a particular folder - then maintenance becomes much easier as any variable you want to add to the mix you would just put into that folder and the script would automatically find it. You'd still need to add the trigger for the variable, but at least you wouldn't have to edit the script every time.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 18, 2015 12:53 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Group based on variables

jay (support) wrote:
You'd still need to add the trigger for the variable, but at least you wouldn't have to edit the script every time.

You could even automate this bit (I think?) - every time the script runs, (or in a separate schedule or action group), have it check for any vars in that folder that don't have a trigger for them, then create or duplicate the trigger definition?


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 22 guests