[ANSWERED] Help on Timers Please

Posted on
Wed Dec 28, 2016 1:43 am
marketability offline
User avatar
Posts: 198
Joined: Dec 08, 2015
Location: UK

[ANSWERED] Help on Timers Please

Struggling here - could be my brain is christmased

I'm working on a motion triggered lighting scene and want to start or restart a timer in python when motion is detected
for the life of me can't work out how to handle timers in python

I think I need to:
a) work out if a timer is running
b) if it is - restart
c) if it isn't - start

all help gratefully received - thanks
Last edited by marketability on Wed Dec 28, 2016 3:06 am, edited 1 time in total.

Posted on
Wed Dec 28, 2016 1:58 am
marketability offline
User avatar
Posts: 198
Joined: Dec 08, 2015
Location: UK

Re: Help on Timers Please

I might be alright - just found the plugin guide and seems I don't need to know the status of a timer
I can just restart it, irrespective of its state

Posted on
Wed Dec 28, 2016 1:59 am
lalisingh offline
Posts: 166
Joined: Mar 27, 2007

Re: Help on Timers Please

The following code toggles a timer.
if timer is running then stop timer else restart it. If you copy/paste this code please check the indentation as it may get mangled.

Code: Select all
id_timer    = 704705687     # Your timer ID
timerPlugin = indigo.server.getPlugin(u"com.perceptiveautomation.indigoplugin.timersandpesters")

if timerPlugin.isEnabled():
   tmr = indigo.devices[id_timer]
   if tmr.enabled:
      if tmr.states['timerStatus'] == "active":
         timerPlugin.executeAction("stopTimer", deviceId=id_timer)
      else:
   timerPlugin.executeAction("restartTimer", deviceId=id_timer)

[url]https://www.VillageWorker.com[/url]
Extreme data analytics, Sensing, Control integration work.
Indigo • Barix • Kentix • Mobotix • Mikrotik • Apple

Posted on
Wed Dec 28, 2016 2:08 am
marketability offline
User avatar
Posts: 198
Joined: Dec 08, 2015
Location: UK

Re: Help on Timers Please

thanks lalisingh - that's much more elegant!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests