Page 1 of 1

[SOLVED]Reset duration and restart

PostPosted: Thu Jun 11, 2015 9:43 am
by ELWOOD
Setting up some timers to control an exhaust fan. Have made 2 action groups that set the timer duration and
start the fan, one for 2 min. and the other for 5 min. Have two buttons on the control page to start the timers.
All works and I can restart a running timer by clicking the control page button. With the 2 min timer running
hitting the the 2 min button the duration resets to 2 mins. With the 2min running hitting the 5min resets
the duration to 5 min and shuts down the fan as expected.

However with the longer 5min timer running hitting the 2 min button the timer goes inactive the duration
goes to 5 min. Hitting the 2min button a second time the timer starts with the duration of 2 min.

Here is the script I use to set the timers, the only difference between the two actions is the duration
setting. Have tried the startTimer and resumeTimer and restartTimer but have not got it to work.

#STOP TIMER
tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
timerPlugin.executeAction("stopTimer", deviceId= 1759204718)



#SET TIME
tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
timerPlugin.executeAction("setTimerStartValue", deviceId= 1759204718, props={'amount':'2', 'amountType':'minutes'})

#START TIMER
tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
timerPlugin.executeAction("startTimer", deviceId= 1759204718)

Thanks for you help
Elwood

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 10:47 am
by howartp
Is this just one Timer device that you're changing the time value on, or two separate timers?

If it's one, I can't think what you can get 'wrong' that would give this result.

If it's two, there's more scope for error.

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 10:58 am
by ELWOOD
howartp

Same timer device and two action groups.

Elwood

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 11:09 am
by howartp
Are those action commands (Stop, Set, Start) all in one script block? (Per action)

If so, try getting rid of the duplication. Just call the plugin/tld bits once, then three executeAction() commands.

Shouldn't (!) have any effect on it but you never know. It is surplus code at the moment anyway.

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 11:26 am
by howartp
I've just duplicated your code (twice) line-for-line on my Indigo, with a test Timer device (changed the ID) and it's working fine for me. (This is without shrinking the duplicate code)

2 minutes or 5 minutes - either one correctly restarts the timer back to the correct time regardless of how long it's going or which action I used last.

Peter

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 11:29 am
by ELWOOD
First started this setup using the pull down menus in the action group setup. With the same trouble. So decided to try python code.
Just did a restart of the mac mini server running indigo, now all is working OK
Go Figure

Thanks
Elwood

Re: Reset duration and restart

PostPosted: Thu Jun 11, 2015 11:29 am
by howartp
Weird :)

Glad it's sorted.