Variable's value as a result of a script?

Posted on
Fri Oct 05, 2018 6:42 pm
boisy offline
User avatar
Posts: 273
Joined: Jun 25, 2013

Variable's value as a result of a script?

I want to create a variable whose value is the result of a script. Why do I want to do this?

For my alarm system, I want to have a variable called 'alarmEnabled' that will be set to TRUE IF:

- my gate is closed
- my two garage doors are closed
- my door sensors are closed

If an attempt to set the alarmEnabled variable to TRUE if any of the above are FALSE, I want to (a) alert the user that the alarm cannot be enabled, and (b) the alarmEnabled value stays FALSE.

This is to prevent arming of the alarm if all conditions aren't in place.

Is there a way to do this?

Posted on
Sat Oct 06, 2018 7:48 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Variable's value as a result of a script?

There seem to be 2 requirements here: some way to easily identify when the condition is true or false, and another to block the variable from changing depending on the condition.

If it were me, I think I'd create a Device Group (one of the Virtual Devices) that contains all the devices (assuming ON means open and OFF means closed) defined as Any device is ON. Then that group represents the "zone" that you've defined such that it only goes OFF when everything is closed.

Then, assuming you were only changing the variable from a Trigger/Schedule, you would just put a condition on those that the zone device has to be off.

It gets more complicated if you want to change the variable in the script, but only in as much as you'd again check the value of the zone device before setting the variable.

The complicated scenario is if you want to manually change the variable. If you want to do that then you'll have to deal with the change after it's happened either via a trigger or via a plugin that monitors the variable for changes and "fixes" it if the change shouldn't have happened in the first place.

As with most things Indigo, there are other ways of doing it, this is just how I would. This is the approach I took when I built an alarm system in my Travel Trailer years ago.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Oct 06, 2018 8:41 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Variable's value as a result of a script?

jay (support) wrote:
If it were me, I think I'd create a Device Group (one of the Virtual Devices) that contains all the devices (assuming ON means open and OFF means closed) defined as Any device is ON. Then that group represents the "zone" that you've defined such that it only goes OFF when everything is closed.

Jay, slightly off topic (apologies Boisy) but just wondering if it's possible to create a Device Group of thermostats? I don't think so, if not is there an easy way to achieve the same functionality with a group of stats (without creating a Virtual Device for each stat)?

Posted on
Sat Oct 06, 2018 8:57 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Variable's value as a result of a script?

lanbrown wrote:
Colly wrote:
jay (support) wrote:
If it were me, I think I'd create a Device Group (one of the Virtual Devices) that contains all the devices (assuming ON means open and OFF means closed) defined as Any device is ON. Then that group represents the "zone" that you've defined such that it only goes OFF when everything is closed.

Jay, slightly off topic (apologies Boisy) but just wondering if it's possible to create a Device Group of thermostats? I don't think so, if not is there an easy way to achieve the same functionality with a group of stats (without creating a Virtual Device for each stat)?


You might want to create your own thread and state what you're trying to accomplish. There is usually more than one way to do something and having a better understanding of what you're trying to do could lead to better results.


+1.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Oct 06, 2018 10:24 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Variable's value as a result of a script?

That's me told! :cry:

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron