Confusion regarding timer actions - start vs. restart

Posted on
Fri Jul 17, 2015 3:03 pm
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Confusion regarding timer actions - start vs. restart

trying to use a timer to implement a timer function for setting HVAC fan mode to "always on" for a specified period of time, after which i want to revert to "auto".

i've used timers in the past for things like monitoring liveness of water detectors. but now i'm digging in a bit deeper and have run into some confusion regarding the docs and what they say about states and actions, mainly so i can put some putting for manipulating the timer in a control page.

i see that there are separate "start" and "restart" actions. what's the difference? wiki documentation states regarding the start action (confusingly) "You can use the Start Timer action at any time and it will reset the amount of time and start the countdown regardless of state (“active”, “paused”, “inactive”). If the timer is already running, it will have no effect." i think there may be a mistake there - or else this is a very confusing way of describing things.

for restart action, it says "use this action to restart a timer using the default time set for the timer. The countdown will be restarted if the timer is already running".

so my intuition tells me that if timer is in inactive state or paused state, then start does the same thing as restart. but if timer is in active state (i.e. timer already counting down), then start does nothing, but restart still forces it to go back to its default start time and then run from there. is that correct? if so, i guess this is just a documentation bug.

it looks like the phrase "regardless of the state ("active", "paused", "inactive")" was possibly mistakenly added to the description start when it was intended to be added to restart? i think that would explain the discrepancy i'm seeing.

Posted on
Fri Jul 17, 2015 4:38 pm
howartp offline
Posts: 3353
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Confusion regarding timer actions - start vs. restart

I think you and the wiki are both wrong.

As I understand it, start just runs the timer from its current value - if that is inactive then it starts from its set value, if it's paused it continues from where it got to. Start from active does nothing.

Restart resets the timer back to its set value and starts it if it isn't running, regardless of its state.


Sent from my iPhone using Tapatalk

Posted on
Fri Jul 17, 2015 5:13 pm
jay (support) offline
Site Admin
User avatar
Posts: 14987
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Confusion regarding timer actions - start vs. restart

Yes, the docs were wrong. I've updated them to reflect the current (and correct) behavior.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jul 17, 2015 9:47 pm
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Re: Confusion regarding timer actions - start vs. restart

very nice. thanks, jay.

Posted on
Fri Jul 17, 2015 11:36 pm
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Re: Confusion regarding timer actions - start vs. restart

i'm putting together a simple control page. on the page, i have four buttons with the following intended actions:
1. start the timer running at 1hr
2. start the timer running at 2hr
3. start the timer running at 4hr
4. stop the timer

in terms of implementation, buttons 1-3 each perform two actions:
set timer start value [to the associated value i.e. 1hr, 2hr or 4hr]
start timer

for some reason, when i click on buttons 1-3 the first time, the timer becomes inactive. on second and subsequent repeated clicks, the timer becomes sets to the appropriate value and counts down.

my understanding is that "set timer" followed by "start" should always leave the timer in an active (running) state, yet sometimes this is not happening. it's seems perhaps there's a race condition or something and the commands are getting executed out of order?

i am displaying the "long timer status" on the control page and i see it unexpectedly display "inactive". i thought it might be that the counter status on the control page out of sync with changes to the actual counter state, but i confirm by viewing the timer directly using the indigo client interface, i confirm that it is "inactive" there as well.

strange thing: if i click on button 1 once, timer becomes inactive. a consecutive click on button 1 starts the timer (as expected). repeated clicks on button 1 reset the timer to 1hr and start it running (as expected). with alternating clicks of buttons 1 and 2 continuously, the timer remains inactive.

am i again misinterpreting the docs? missing something about timing or logic of how commands executed from control pages?

Posted on
Tue Jul 21, 2015 8:43 am
jay (support) offline
Site Admin
User avatar
Posts: 14987
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Confusion regarding timer actions - start vs. restart

The order of execution on actions in the same trigger, schedule, or action group, is undefined - so it's likely that sometimes the start command gets executed first followed by setting the time - which would stop the timer. Add a 1 second delay to the start action and that should work.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 21, 2015 10:51 am
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Re: Confusion regarding timer actions - start vs. restart

thanks - probably one of those little tidbits i learned a long time back and have forgotten a few times already.

to check my understanding, a list of actions in an action group, trigger, etc. can happen in any order. otoh, if i had a single action of type server actions>script and file actions> execute script and this script consisted of script (applescript or python) with the same actions then that would be guaranteed to execute the steps in order - is that correct? if so, is using a script the preferred/accepted method of serializing commands?

a side-comment/question: wouldn't it be easy to modify the indigo to do in-order execution of actions in a list? and wouldn't this be "better" in the sense of being more intuitive? was letting things happen asynchronously / in parallel seen as a "good thing" for improving indigo responsiveness or something? also, is it not a wee bit misleading that the indigo interface for creating/editing lists of actions has buttons labeled "up" and "down"? since this at least implies that the order matters, which in turn weakly implies serialization of the commands, absent some explanation/warning to the contrary?

Posted on
Tue Jul 21, 2015 11:18 am
jay (support) offline
Site Admin
User avatar
Posts: 14987
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Confusion regarding timer actions - start vs. restart

dduff617 wrote:
to check my understanding, a list of actions in an action group, trigger, etc. can happen in any order. otoh, if i had a single action of type server actions>script and file actions> execute script and this script consisted of script (applescript or python) with the same actions then that would be guaranteed to execute the steps in order - is that correct? if so, is using a script the preferred/accepted method of serializing commands?


Correct (mostly). The nature of using a script is that each line of the script is executed after the former line is completed, so it's inherently synchronous. The possible exception is whatever is performing the action you specify. If you tell a light to turn on and then tell another light to turn on, then it would depend on what the implementation of said technologies were. So, for instance, if the first turn on is to an Insteon device, and the second is to a Z-Wave device, it might very well appear that the Z-Wave device turns on before the Insteon device. This is because Indigo queues up the Insteon command to the PowerLinc and immediately returns. The same happens with the Z-Wave device. But because Z-Wave is faster than Insteon (in general), it might actually process more quickly. Another example would be a plugin that queues up commands to perform - it could, for instance, prioritize some actions above others (or even use a stack rather than a queue) so again the order of execution wouldn't necessarily be what someone might assume.

So the answer isn't a solid yes. I definitely wouldn't say that scripting is the preferred method, since adding a slight delay's is a perfectly acceptable/reasonable way of accomplishing it, and it's generally much easier than writing a script.

dduff617 wrote:
a side-comment/question: wouldn't it be easy to modify the indigo to do in-order execution of actions in a list? and wouldn't this be "better" in the sense of being more intuitive? was letting things happen asynchronously / in parallel seen as a "good thing" for improving indigo responsiveness or something? also, is it not a wee bit misleading that the indigo interface for creating/editing lists of actions has buttons labeled "up" and "down"? since this at least implies that the order matters, which in turn weakly implies serialization of the commands, absent some explanation/warning to the contrary?


The discussion above explains one reason why Indigo doesn't attempt to force action execution order. The other is that in the vast majority of cases, order isn't important, and making actions as asynchronous as possible makes Indigo much more responsive. Trying to force order, particularly now with plugins in which we can't guarantee anything, is in fact a non-trivial undertaking with very little benefit.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 21, 2015 11:52 am
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Re: Confusion regarding timer actions - start vs. restart

yes, each of buttons 1, 2, and 3 has a server action consisting of three actions, thus:
set fan mode "L2 Thermostat" to always on
set timer start value
start timer

when i bring up the control page (from the "browser preview" button, in case it matters), it pops up as expected. BTW, this control page also displays the device state of L2 thermostat and also displays the state of the timer, plus outdoor temp and humidity.

i click button 1. the fan switches to always on. the timer stays "inactive".
i click button 1 a second time. fan remains always on. timer jumps to 1:00:00 and starts counting down.
click button 1 a third time. fan remains on. timer jumps back to 1:00:00 and starts counting down.

... (same thing on all consecutive clicks on the button 1)
i click button 2. fan remains always on. timer becomes "inactive".
i click button 2 a second time. fan remains always on. timer jumps to 2:00:00 and starts counting down.
i click button 1. the fan switches to always on. the timer stays "inactive".

so this pattern is repeatable across all three buttons. when i click a button the first time (consecutively), it unexpectedly causes the timer to become inactive. second and subsequent consecutive clicks on the same button behaves as i intended.

so it appears that the way the timer becomes inactive is if the set-timer-start action is happening after the start-timer action. based on what you said above, it makes sense that that could happen. why the differences in execution sequence happen with the strange but predicable pattern i describe above, i can't even guess.
Last edited by dduff617 on Tue Jul 21, 2015 11:57 am, edited 1 time in total.

Posted on
Tue Jul 21, 2015 11:56 am
dduff617 offline
Posts: 428
Joined: Jul 05, 2006

Re: Confusion regarding timer actions - start vs. restart

attaching a quick screen cap of the interface
Attachments
thermostat control page.tiff
thermostat control page.tiff (361.5 KiB) Viewed 1695 times

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests