Timer (Count UP)

Posted on
Sun Jan 08, 2017 11:04 pm
SQLGOD offline
Posts: 10
Joined: Jan 08, 2017

Timer (Count UP)

I currently use HomeSeer Pro and am looking at converting to Indigo to provide a more stable environment, especially for Insteon automation. I have over a hundred devices, hundreds of events and I make extensive use of timers to determine how long a scene (Insteon, Sonos, Hue, Z-Wave, etc.) should stay on (with shorter periods for later parts of day or late night, or weekdays, etc.), what amount to dim before final inactivation, etc. I've reviewed the Timers & Pesters plugin, which could be used to cover this requirement, but it would require quite a bit more coding to work around the functionality I need. Is there a plugin or function I'm not seeing that will create a timer which counts UP (0, 1, 2, 3, 4...) that can then be reset when activity occurs and can trigger different functions/scenes when different milestones in the count are reached?

Posted on
Mon Jan 09, 2017 3:21 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Timer (Count UP)

There's nothing built-in. Can you describe your use cases with some more detail? There may be a different approach to solving your specific problem given the differences in how Indigo works.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jan 09, 2017 8:56 pm
SQLGOD offline
Posts: 10
Joined: Jan 08, 2017

Re: Timer (Count UP)

Jay,

Thanks for the quick reply. Below are some additional details / examples on how I use (count up) timers and comparable functionality I'm looking to identify and use.

1) Initiate a timer when all motion sensors in a room become 'no motion'. Timer then starts counting up (not dependent on any one particular end-time at this point). Timer then gets stopped and reset to zero if any motion sensor shows movement. Amount of time before an event is triggered (if timer is not reset by activity) is not constant, however, but is dependent on many other factors, so it is a significant benefit to not have a fixed counter going down. Even if I set the timer at a very high number, I'd still have to do calculations for every time segment I wanted to evaluate, vs. just saying at 5 minutes or at 10 minutes or at 1 hour, check this. I'm also not sure Indigo timer can react to multiple time frames w/o creating multiple timers. If my HS timer gets to, say, 15 minutes during the day (with no motion resetting it), then trigger also evaluates other variables and device values and if all requirements are not met, continues on with count; if all are met, then it sets the timer to zero and closes the governed scene. The same timer trigger has multiple OR statements in the trigger that re-evaluate the timer at various values and against various other requirements, without breaking that trigger into multiple triggers or multiple timers.

Example:
IF tmrKitchen becomes 2 minutes 30 seconds AND tmrManualOverride = 0 (e.g. override not activated) AND (time is before 5:30AM OR time is after 10PM) AND tmrAutomationOff = 0

OR

IF tmrKitchen becomes 15 minutes AND tmrManualOverride = 0 (e.g. override not activated) AND (time is after 5:29AM AND time is before 8:01PM) AND tmrAutomationOff = 0

OR

IF tmrKitchen becomes 10 minutes AND tmrManualOverride = 0 (e.g. override not activated) AND (time is after 8PM AND before 10:01PM) AND tmrAutomationOff = 0

OR (other logic here to see if a wall or remote button was pushed which manually turns of the scene)

OR (other logic after extended time frame to turn off any temporary manual override or other logic to turn full automation back on)

THEN SET Scene-XYZ to OFF (and reset other timers and devices and variables)...

The same functionality is used for multiple scenes with multiple timers within the same room, such as a multi-media timer, lighting scene timer, TV timer, away timer and a backup / fail-safe 'kill all' timer. At any one time, I could have several dozen timers going, so I'm looking for a solution that does not eat up CPU cycles nor impact responsiveness to other events/triggers. Key here is that I can keep reacting to timer-count-based events as the timer goes up (without ending the timer count) and at any point in the timer (2 seconds, again at 2 minutes, then at 5 minutes, then 2 hours, etc.) I can trigger another event sequence (if all requirements are met) without creating a different timer for each time of day and requirements and with distinctive 'off times'.

2) The other key use for timers is to allow users to set a 'mini-automation on/off' variable (which would ignore the above on/off functionality by comparing the value of the 'tmrKitchenManualOverride' in the event trigger above and if this timer is anything but 0, then don't trigger the event because user has requested manual operation vs. automation). Two layers of manual override exist, one shorter term (like for 30 minute or an hour or 12 hours depending on the room and day, etc.) for when a user manually presses a switch, and a longer full 'turn automation off' which is normally driven by telling Alexa to 'Turn Off Kitchen Automation' and would have a reset timer of a day or similar time frame if not reverted manually.

If built in functionality does not exist, I'm good with scripting as long as I can stay away from code which degrades system performance and that doesn't require separate routines for every variation of a trigger event (vs. having condensed logic using multiple AND/OR/NOR type comparisons).

Appreciate any direction you can provide.

...

Posted on
Tue Jan 10, 2017 7:05 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Timer (Count UP)

Interestingly/oddly, this is the first time I've heard this use-case.

There are some things that are probably more limited than what you need, but you can do an auto-off for any given action that turns on a light. You can also have any previous auto-off (or auto-on's) cancelled for a given device. That might solve some of your issues.

There's also a 3rd party plugin called Powermiser that may help with that as well as it exposes some extra functionality around auto-offs.

For the level of functionality that you want, however, you'll likely need to build your own script which implements a light state machine (probably using variables or something). If you implement your script(s) as external scripts, they will be executed in their own process and thus shouldn't effect overall system performance.

Another option would be to build a plugin that implements upwards counting timers. In fact, you might find one of our 3rd party developers here on the forums that might want to tackle it. Building a plugin itself isn't very difficult though from my experience building the Timers plugin the implementation can get somewhat complex. But it's certainly doable though. Plugins also run in their own process so the chances of them impacting the server are reduced (though not entirely eliminated as there are a few bottlenecks).

One bit of advice however - Indigo and Homeseer present automation concepts/solutions in different ways, some significantly different. It's generally worth spending some time understanding the basic objects in Indigo and how those work together before trying something very complex. We've seen switchers from other platforms trying to exactly replicate what they did and spent a huge amount of time, only to find that a good rethink on the use-case (as opposed to the technical solution) would have shown them a different approach in Indigo that would have been much simpler. That may not be the case with you, but just a thought/observation.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 11, 2017 7:29 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: Timer (Count UP)

The way I was looking at it, it could be handled with the long ago requested (but too complex to implement) request for moving the conditions onto the individual actions; as in

when something initiates the Kitchen ON trigger, there could be a delayed action to turn off the light after a 2 minute and 30 second delay if the conditions were tmrManualOverride = 0 (e.g. override not activated) AND (time is before 5:30AM OR time is after 10PM) AND tmrAutomationOff = 0 at the time the action fires

and another delayed action after 15 minutes to turn off the light if the conditions are tmrManualOverride = 0 (e.g. override not activated) AND (time is after 5:29AM AND time is before 8:01PM) AND tmrAutomationOff = 0 at the time the action fires

and etc..

And if the Manual Override and AutoonOff conditions weren't going to change between the time the trigger is started and the delayed off occurs, you could implement it now with multiple triggers...

Posted on
Wed Jan 11, 2017 8:22 am
krissh offline
Posts: 105
Joined: Nov 18, 2012
Location: Norway

Re: Timer (Count UP)

One solution could be
  • Create a timer with 2 minutes 30 seconds
  • Start the timer on Kitchen ON/motion on
  • Every time the timer reaches zero add 150 (seconds) to a variable

Then use the value of the variable as conditions in the triggers. Reset timer/variable as appropriate.

Posted on
Wed Jan 11, 2017 11:41 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Timer (Count UP)

Another option that just occurred to me: you could write an external script that just increments an Indigo variable. You then create triggers for when the variable value becomes whatever, use the built-in conditions to specify the condition, then perform whatever actions.

The trick is how to stop the script when you don't need it running any more. One option would be to have the script periodically check the value of another variable to determine if it should increment the variable or shutdown (and reset the variable value to 0 or something). So you might have 2 variables: script_counter and script_shouldrun. counter would be the countup and shouldrun would be true or false (or whatever).

Not fully fleshed out obviously, but I think you get the idea.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 11, 2017 11:43 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Timer (Count UP)

One other pointer: you might check out the SecondsSinceLastChange plugin. I've never personally used it, but seems like that might help in this scenario.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests