Author |
|
Handman Senior Member
Joined: February 02 2009 Location: United States
Online Status: Offline Posts: 229
|
Posted: February 13 2010 at 16:31 | IP Logged
|
|
|
My wife has a tendency of walking outside and turning on all the yard lights at night and then never turning them off. I then created a macro that turned the yard lights off in ten minutes. I now want a way to override the macro so the lights stay on under the right circumstances. In this case I want the Insteon light switch to turn on the lights and start the (off) timer macro. Then, if the same light switch is turned on while the lights are already on, it executes a killmacrowait to kill the waiting macro. I have one trigger that starts the 10 minute timer macro and another that looks at the status of one of the outdoor lights and then either runs ph_killmacrowait if the Boolean field is positive for the light being illuminated, or it doesn't run the macro if the light was not illuminated. The problem I am running into is that depending on which trigger fires first (alphabetically??), the macro sequence either fires and just restarts the timer, or if I build a delay into the macro, it ends up killing all the waiting timers every time the light is turned on. Suggestions for getting the sequence right would be appreciated.
Edited by Handman - February 13 2010 at 16:32
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 13 2010 at 21:32 | IP Logged
|
|
|
I would put all the logic in a single macro. That way you do not care about execution order of multiple macros triggered from the same condition.
__________________ Lee G
|
Back to Top |
|
|
Handman Senior Member
Joined: February 02 2009 Location: United States
Online Status: Offline Posts: 229
|
Posted: February 17 2010 at 00:00 | IP Logged
|
|
|
Still having problems. Is there a simple function to find out the status of an insteon device five seconds ago? For example, I am using the device status of ON to trigger a macro. I then want to know if the device was ON or OFF five seconds before the most recent ON triggered the macro. If the device was OFF, then I want a timer to turn it off in ten minutes, but if the device was already ON, the I want to kill any running timers to turn off the light. This function would be used to override a waiting macro.
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 17 2010 at 02:42 | IP Logged
|
|
|
You can use local variables to determine existing state when a macro is called. LOCAL9 has a value of device state when the Insteon message is received and LOCAL10 has a value indicating new state.
Example: I trigger a macro when I press an ICON switch ON.
The following are the local variables when the ICON is Off, going to ON
local1= local2= local3= local4= local5= local6= local7= ICON SWITCH TEST local8= 04.56.50 local9= 0 local10= 255
The following are the local variable when the ICON is ON, going to ON
local1= local2= local3= local4= local5= local6= local7= ICON SWITCH TEST local8= 04.56.50 local9= 255 local10= 255
Note that local9 is 0 when device is OFF, going to ON and local9 is 255 when device is ON, going to ON.
In the macro you initially kill a waiting macro, you do not care if one is waiting for not. Next check local9 for 255 (ON). If the current state is 255 (ON) you exit the macro. If the current state is 0 (OFF) you Wait for 10 minutes and issue an OFF Insteon command when the Wait completes. If the Wait completes the 10 minute timer elapsed from a single ON press and the device is turned OFF. Otherwise, an ON with the device already ON cancelled the previous waiting macro and the device remains ON until manually turned OFF.
If you want to maintain your 5 second ON to ON store the current time in a Global variable. Before updating the Global variable check the current Global variable value against current time to see if 5 seconds have elapsed and base the exit versus wait on the elapsed time check and ON to ON rather than just ON to ON.
EDIT: another approach is to base the Wait using ON versus Fast ON commands. An ON command always triggers macro A which always cancels any waiting macro and sets a Wait and OFF 10 minutes later. A Fast ON (double Tap of switch) triggers macro B which always cancels macro A. You should have a macro triggered by an OFF command which cancels macro A. That way if the switch is explicitly turned OFF no waiting macro remains to confuse the issue if before the 10 wait completes the switch is turned ON again.
Edited by grif091 - February 17 2010 at 02:59
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: February 17 2010 at 09:24 | IP Logged
|
|
|
I use one timer event and then modify it when any changes in the wait occur. I found this to be more productive than issuing a wait from the macro. You can test all the conditions from a Boolean and then modify the time event accordingly. In your case the time event probably would issue an OFF to the device. Just my 2 cents…
__________________ Pete - X10 Oldie
|
Back to Top |
|
|