timer script vs timer plugin

Posted on
Sun Nov 15, 2015 10:16 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

timer script vs timer plugin

Hello All,

I used to use the timer script (http://www.indigodomo.com/library/98/) and I'm curious if the timer plugin can do the same. On my old system my kitchen lights were setup on a 60 minute timer to automatically turn off. They would dim down 30% and then back to 100% 5 minutes before the lights would turn off. If we wanted the lights to stay on we would push the lights ON button to add an addition 30 minutes to the timer. Each push to the ON button would add an additional 30 minutes up to a maximum of 2 hours.

I've played with the plugin a little and I figured out the 60 min start and the 30% down then back up to 100% 5 minutes before they go off. However I can't figure out :cry: how to add the addition 30 minutes up to a max of 2 hours with each push of the ON switch.

Is there a way to do this with the Timer plugin?

Edmond

Posted on
Mon Nov 16, 2015 12:33 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: timer script vs timer plugin

I've never actually looked at that script, so I'm not sure how it works.

There are timer actions to set the start value and to start the timer.

Your scenario is fairly complex so you're going to need some extra logic - perhaps multiple timers. It may, in fact, be more convoluted than the script you're using. Can you describe how it's currently working in more detail (what are the parts of the solution, etc)?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 16, 2015 1:33 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: timer script vs timer plugin

OK here is what I do to make it work. I hope it makes sense.

The timer requires the timer script to be loaded at startup, 6 Triggers and one Variable.

1st Trigger: On for 60 minutes
Trigger, device changed, kitchen light, Becomes ON.
Condition, If variable KitchenTimer is less then 1
Action, Modify Variable KitchenTimer, Set to 3600

2nd Trigger: Add 30 minutes to timer
Trigger, Insteon Command Received, kitchen light, ON.
Condition, If variable KitchenTimer is Greater then 1
Action, Execute Script: Embedded AppleScript
Code: Select all
set value of variable "TimerKitchen" to (value of variable "TimerKitchen") + 1800

3rd Trigger: 5 minute warning
Trigger, Variable Changed, KithenTimer, Becomes less 315
Condition, If variable KitchenTimer is Greater then 299
Action, Dim by 30% then Brighten by 30%

4th Trigger: AutoOff
Trigger, Variable Changed, KithenTimer, Becomes Equal to 0
Condition, Always
Action, Turn Off Kitchen Light

5th Trigger: Manual Off
Trigger, device changed, kitchen light, Becomes OFF
Condition, Always
Action, Modify Variable KitchenTimer, Set to 0

6th Trigger: AutoOff
Trigger, Variable Changed, KithenTimer, Becomes Greater to 7201
Condition, Always
Action, Modify Variable KitchenTimer, Set to 7200

What do you think? Should I keep using this solution or do you think we can do something easier with the plugin?

Edmond

Posted on
Tue Nov 17, 2015 5:10 pm
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

Re: timer script vs timer plugin

Hi,

Your subject gave me some idea with my system. I've setup something that can be useful for you. You have to create one timer (with Indigo plugin activated) and four triggers. Here my receipe:

Timer #1 : Unit = Minutes

Trigger #1 / Timer set delay an start timer
Trigger : Switch ON (insteon cmd) / Use instead cmd because you can capture many "on".
Condition : Always
Action : Embedded script
Code: Select all
id_timer    = 299731133      # Your timer ID
id_switch   = 821872148      # Your switch 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'] == u"active":
         dT = int(tmr.states['timeLeftMinutes'])
         if 0 < dT < 29:
            dT = 30
         elif 29 <= dT < 59:
            dT = 60
         elif 59 <= dT < 89:
            dT = 90
         else:
            dT = 120

         # Send feedback
         dev = indigo.devices[id_switch]
         indigo.device.beep(dev)
      else:
         # First click
         dT = 60         # Default

      timerPlugin.executeAction(u"setTimerStartValue", deviceId=id_timer, props={'amount':str(dT), 'amountType':'minutes'})
      timerPlugin.executeAction(u"startTimer", deviceId=id_timer)

Trigger #2 / Stop timer
Trigger : Switch OFF
Condition : Always
Action : Stop Timer

Trigger #3 / Light signal that we will close in 5 minutes
Trigger : Time left in Minutes = 5
Condition : if Timer Status is Active = True
Actions : Set DIM to 30% + Set DIM to 100% with delay action of 3s

Trigger #4 / Timer Expired
Trigger: Timer Expired
Condition: Always
Action : Set DIM to 0% (turn off)

It works for me! I hope that will help you!

Joël

Posted on
Thu Nov 19, 2015 9:21 am
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: timer script vs timer plugin

Hello Joël,

Thanks for the info. I'll try it out tonight.

I am not familiar (yet) with python scripting, however it looks like the Switch ID at the top of your script is used below to send an audible beep to the Insteon switch? Is that correct? I have two switches turning on and off the kitchen lights. How would I need to add the second switch?

Also, I'm assuming that when I setup the timer I need to set the Initial Amount to 60, correct?

Thanks for your help

Edmond

Posted on
Thu Nov 19, 2015 10:55 am
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

Re: timer script vs timer plugin

Hi,

At the first press switch, the script will initialize the value to 60 minutes for you.

The beep is optional but it funny to have a feedback at the switch. Insteon switch has this feature, why not use it! Yes, the 'id_switch' is only for the user feedback (aka beep). If you have other switch, simply copy the two lines and create a new variable (e.g. 'id_switch2) with the other id number (right click on your device and select 'copy id').

For the python code, it's will be a great tutorial for you! :)

Thanks!

Joël

Posted on
Thu Nov 19, 2015 11:14 am
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: timer script vs timer plugin

Hey Joël,

At the first press switch, the script will initialize the value to 60 minutes for you.
Cool, So what value do I need to put when configuring the timer? It's requiring something, should I just put 60? Looks like the script will override whatever is in that field so it probably doesn't matter.


The beep is optional but it funny to have a feedback at the switch. Insteon switch has this feature, why not use it! Yes, the 'id_switch' is only for the user feedback (aka beep). If you have other switch, simply copy the two lines and create a new variable (e.g. 'id_switch2) with the other id number (right click on your device and select 'copy id').
The beep is cool. So something like this:
Code: Select all
id_timer    = 299731133      # Your timer ID
id_switch   = 821872148      # Your switch ID
id_switch2   = 123456789      # Your switch 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'] == u"active":
         dT = int(tmr.states['timeLeftMinutes'])
         if 0 < dT < 29:
            dT = 30
         elif 29 <= dT < 59:
            dT = 60
         elif 59 <= dT < 89:
            dT = 90
         else:
            dT = 120

         # Send feedback
         dev = indigo.devices[id_switch]
         indigo.device.beep(dev)
         dev = indigo.devices[id_switch2]
         indigo.device.beep(dev)
      else:
         # First click
         dT = 60         # Default

      timerPlugin.executeAction(u"setTimerStartValue", deviceId=id_timer, props={'amount':str(dT), 'amountType':'minutes'})
      timerPlugin.executeAction(u"startTimer", deviceId=id_timer)


For the python code, it's will be a great tutorial for you! :)

What will be a great tutorial :?

Thanks Again
Edmond

Posted on
Fri Nov 20, 2015 8:29 pm
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

Re: timer script vs timer plugin

I meant play with python code can be a great tutorial! :)

Thanks!

Joël

Posted on
Sun Nov 22, 2015 1:54 am
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: timer script vs timer plugin

Thanks for your help Joël

It works nice :D , however I can't increase the timer by pushing the second switch thats linked to the kitchen. If I push switch 1 both switch 1 and 2 beep and the timer increases, however if I push switch 2 to try and increase the timer nothing happens. Any ideas?

Edmond

Posted on
Mon Nov 23, 2015 6:53 am
jblackburn offline
Posts: 77
Joined: Dec 11, 2013
Location: Quebec, Canada

Re: timer script vs timer plugin

Sorry, I’ve tested with only one switch... Anyway, it is the same logic! One drawback of an trigger item in Indigo, we cannot have more than one condition (e.g. switch 1 AND switch 2). In this case, you should duplicate trigger #1 & #2 for each switch with the same logic applied. You can set the beep for each switch and both actions can manage the same timer.

Thanks!

Posted on
Mon Nov 30, 2015 10:50 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: timer script vs timer plugin

jblackburn wrote:
One drawback of an trigger item in Indigo, we cannot have more than one condition (e.g. switch 1 AND switch 2).

Actually you can - have a look at either virtual devices, or the virtual group trigger, depending on your needs.

I'd use a virtual device that goes on when both 1 & 2 are on, then trigger on that.


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests