I have the following situation: Light A is controlled by a contractor (basically a bi-stable latching relay). Each time the contractor is pulsed it changes state (toggles) between On and Off. The contractor is actually two switches in one. Switch 1 controls light A while switch 2 controls connects to a digital input (DI) on an I/O board that is visible to Indigo. Indigo can also control a relay on the I/O board to operate the contractor. Thus, I can control the contractor, and the connected light, by local push-buttons or via Indigo, and Indigo knows the state of the contractor, and by extension, the light. All of this works well and is the basis for a Virtual Device in Indigo.
I also have a trigger that looks for my gate to open and will then turn on light A. A condition in the trigger requires the contractor be Off for the action to take place. Otherwise, if light A were on when the gate opened, it would be turned off (toggled). All good so far. However, I want light A to turn off 10 minutes after the gate opens. I can configure trigger to auto-off after 10 minutes (or add a second a action to do that after a delay of 10 minutes). The problem is if someone has manually turned light A during the 10 minute period, the trigger will actually turn it back on (since light A is only a toggle with no specific On/Off state). So, I only want the trigger to toggle light A if it is already On.
My solution was to add a second action to my trigger, with a delay of 10 minutes. This action sets a variable to True. I then have a second trigger keyed to that variable, with the condition that Light A be on, and one action to toggle light and a second action to set the variable to False. I effectively push the condition check out 10 minutes. This all works.
My question is, is there a more direct way to do this? Allowing Triggers to define conditions for each of multiple actions (evaluated at execution time) would address the issue, as would allowing Action Groups to have conditions. However, I am not sure either idea would really benefit Indigo and might add more confusion than help. Another approach might be to build a seemingly stateful Virtual Device front end for something that is truly only a toggle. So, it it were set to On, it would first check the current state and then only operate if it were currently Off. This could probably be done by embedding code in the Virtual Device's Action Groups. But, it seems like it would end up being more complex than my current solution.
So, has anyone else dealt with a situation like this? Or does someone have some thoughts, comments or ideas on the topic?