Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: using wait Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ward
Newbie
Newbie


Joined: November 28 2001
Location: United States
Online Status: Offline
Posts: 1
Posted: November 28 2001 at 14:54 | IP Logged Quote ward

After reading over the manual
(admittedly, quite quickly), it
is unclear what happens in the
following situation...
a motion sensor indicates movement
which triggers a macro which
turns the light on and then 'wait's
to turn it off. Then, before
the light is turned off, motion is
again detected. It would seem that
the macro would be run again and
it should detect that the light is
on and simply terminate. However,
this will not adjust the 'wait'
correctly if I want "The light will
stay on 15 minutes after motion is
detected".

How would I program that function?
Many thanks, this looks package looks very cool.
Back to Top View ward's Profile Search for other posts by ward
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 01 2001 at 15:28 | IP Logged Quote dhoward

Ward,

You are correct in that the macro would again be executed as a separate instance. You could obtain the functionality that you want by using a global variable to keep track of the other macros. There are a number of different ways that you could accomplish this. I'll detail one that comes to mind...

Declare a global variable which will hold the time the light should be turned off...ie 15 minutes into the future.

When your macro executes from motion being detected, have it update this global variable with the current time plus 15 minutes ( or 14 mins, 59 seconds to resolve any timing issues). Then have your macro wait for 15 minutes. When the macro resumes execution, have it check the global variable and compare it to the current time. If the current time is greater than the global, then shut the light off. This way every time motion is detected, a new macro will spawn and set the global to 15 minutes from when motion was detected. If the current time is not greater than the global, just have the macro exit as another macro will be timing out soon.

Let me know if this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum