Charmed Quark Systems, Ltd. - Support Forums and Community
Action wait and exit if variable changes - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: General Discussion (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=3)
+--- Forum: CQC Support (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=9)
+--- Thread: Action wait and exit if variable changes (/showthread.php?tid=11039)



Action wait and exit if variable changes - simplextech - 01-31-2020

I'm trying to mimic a wait routine in the ISY that when triggered will wait a period of time and if one of the trigger parameters change then the program will exit until triggered again.

The setup is this.

Var: GarageCameraMotion (bool)
Var: GarageDoorOpen (bool)

Trigger:

Is New field value for: GarageCameraMotion = False
Field value Equals: GarageDoorOpen = True

Trying to figure out the Action for waiting 5 minutes and then closing the garage door.  The difference is that during that 5 minute period if GarageCameraMotion changes to be True I want the Action to terminate (no error).


RE: Action wait and exit if variable changes - Dean Roddey - 02-01-2020

That's what Devices::TimedFldWrite is for. Normally you use it to write a different first value from what the field currently is, but you can write the same value. So, when it happens, called timed field write on the garage door closer with open as the first value and closed as the second, and five minutes as the timeout. If you never write anything else to that field, then when five minutes is up, it will do the second value for you. If you want to cancel it just do a regular field write to the field (or if the driver sees it change state it will cancel as well.)

You will have to keep up with changes in the motion state of course.

Another option might be to set that motion sensor to have a 5 minute reset. Some motion sensors let you set how long it waits before it goes back to non-motion. If so, that would solve it automatically pretty much.


RE: Action wait and exit if variable changes - simplextech - 02-01-2020

(02-01-2020, 07:28 AM)Dean Roddey Wrote: That's what Devices::TimedFldWrite is for. Normally you use it to write a different first value from what the field currently is, but you can write the same value. So, when it happens, called timed field write on the garage door closer with open as the first value and closed as the second, and five minutes as the timeout. If you never write anything else to that field, then when five minutes is up, it will do the second value for you. If you want to cancel it just do a regular field write to the field (or if the driver sees it change state it will cancel as well.)

You will have to keep up with changes in the motion state of course.

Another option might be to set that motion sensor to have a 5 minute reset. Some motion sensors let you set how long it waits before it goes back to non-motion. If so, that would solve it automatically pretty much.

TimedFldWrite won't work as the ISYv2 Driver does not support Scenes or the IOLinc device (sensor/relay).  The ISYv1 driver doesn't work with the TimeFldWrite for the scene controls.  

The motion is from my NVR setting the variable via HTTP Trigger.  When there's motion it sets the variable true when motion ends it sets the variable false.

I have a few events setup where I'm having to use a HTTP Trigger from the ISY to set variables then have CQC react based on them and then use a CML Macro to do the HTTP Get back to the ISY to turn on/off the scenes as needed.


RE: Action wait and exit if variable changes - Dean Roddey - 02-01-2020

You could always just create a MotionTimeout field in the variables driver as well, and do the timed write on it. So set it true when motion starts and with a five minute delay to write false back to it (and if you call timed field write again on another motion that'll just reset the timeout periods again.) If you write to it normally, that'll cancel the completion of the timed write.

Then trigger on that field going false.


RE: Action wait and exit if variable changes - simplextech - 02-01-2020

(02-01-2020, 10:34 AM)Dean Roddey Wrote: You could always just create a MotionTimeout field in the variables driver as well, and do the timed write on it. So set it true when motion starts and with a five minute delay to write false back to it (and if you call timed field write again on another motion that'll just reset the timeout periods again.) If you write to it normally, that'll cancel the completion of the timed write.

Then trigger on that field going false.

Perfect.  I think that will work.  You also got me thinking of finding (for now) an older Insteon Motion sensor that does the timeout properly and setting that up as a temp solution.  This variable with a time write I think will work well.


RE: Action wait and exit if variable changes - Dean Roddey - 02-01-2020

You may need it to be an enumerated value. You need (active, timedout, and cancelled.) If you did a boolean and just cancelled the operation by writing false, that would cause the trigger to go out. If you have three states, you can handle all the scenarios. Only trigger if it goes to timedout (which will be the final value of the timed write.) To cancel just write cancelled to the field normally and the timed write will be dropped.


RE: Action wait and exit if variable changes - simplextech - 02-01-2020

Would I use a StringList for the variable then?


RE: Action wait and exit if variable changes - Dean Roddey - 02-01-2020

No, just a string with an enumerated limit with those three values.


RE: Action wait and exit if variable changes - simplextech - 02-01-2020

(02-01-2020, 11:47 AM)Dean Roddey Wrote: No, just a string with an enumerated limit with those three values.

Ok.  I was checking the options for the variable is why I asked.