Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Buffered Occupency (Time delayed actions) Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: February 11 2005 at 18:08 | IP Logged Quote onhiatus

So I've got my thermostat automated, and I've got a motion detector. What I'd like to happen is have the thermostat get turned up after 3 minutes of continuous occupency, and turned off after 10 minutes of continuous absence. Basically I want to implement a buffered occupency sensor.

I've worked out a way to do this, but it seems awkward and very tempermental. I'd like to know if someone has a more elegant way of doing it.

First off, my motion sense is one of the x10 ones (it sends an A16 ON when movement is detected, and an A16 OFF after 1 minute of no movement)

I don't have my actual macro sitting in front of me but here is the pseudo code:

Triggers:
Triger1 is on A16 ON, runs macro StartOccupied
Triger2 is on A16 OFF, runs macro StartUnOccupied

Globals:
Occupied - The room is already marked occupied
Running - One of the occupied macros is mid run
rOn - An A16 ON has been recieved
rOff - An A16 OFF has been recieved

Macro: StartOccupied:
- - if (Running)
- - - - set rOn
- - - - exit
- - else
- - - - if (occupied) exit
- - - - set Running
- - - - set rOn
- - - - Clear rOff
- - - - set timed event: in 3 minutes run CheckOccupied

Macro: StartUnOccupied:
- - if (Running)
- - - - set rOff
- - - - exit
- - else
- - - - if (Not occupied) exit
- - - - set Running
- - - - set rOff
- - - - Clear rOn
- - - - set timed event: in 10 min run CheckUnOccupied

Macro: CheckOccupied
- - if (not rOff) run SetOccupied
- - clear rOn
- - clear rOff
- - clear Running

Macro: CheckUnOccupied
- - if (not rOn) run SetUnOccupied
- - clear rOn
- - clear rOff
- - clear Running

Macros SetOccupied and SetUnOccupied set a global variable as a flag for other macros and turn on / off the heat.

Is there a simpler way to do this?

Thanks, Tony

Edited by onhiatus
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 14 2005 at 16:09 | IP Logged Quote dhoward

Tony,

Based upon your criteria, I would do it the following way. It's psuedocode and may not be any more elegant than yours, but I submit it for further thought.

Triggers:
Triger1 is on A16 ON, runs macro StartOccupied
Triger2 is on A16 OFF, runs macro StartUnOccupied

Globals:
Occupied - The room is already marked occupied

Macro: StartOccupied:
- - if (macro StartUnoccupied is waiting) then kill StartUnoccupied macro
- - if (Occupied) then exit
- - if (macro StartOccupied is waiting) then exit
- - Wait 3 minutes
- - Set Occupied
- - Set Thermostat

Macro: StartUnOccupied:
- - if (macro StartOccupied is waiting) then kill StartOccupied macro
- - if (Not Occupied) then exit
- - if (macro StartUnoccupied is waiting) then exit
- - Wait 10 minutes
- - Clear Occupied
- - Setback Thermostat

Ive just run it through my head and I think it meets your requirements.

Let me know,

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

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: February 14 2005 at 17:35 | IP Logged Quote onhiatus

You can kill a macro??? That does make life a lot easier - and not just for this macro. I'll need to dig up the documentation on that...

What happens when a macro is waiting - this doesn't hang the entire macro queue? How are macros processed?

Thanks, Tony
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: February 14 2005 at 19:40 | IP Logged Quote TonyNo

Yup. Makes a lot of things easier.

From the docs...

This command will suspend execution of the current macro but is different from the Delay command in that it will NOT stop the execution queue from processing waiting commands. The macro is actually terminated but the System Variables [LOCAL1] thru [MACRO10] and [TEMP1] thru [TEMP10] are stored and a timer started. When the timer is up, the macro is reinserted into the execution queue and will resume processing at the statement following the Wait command. Enter a formula that evaluates to the number of seconds you would like to wait in the Send Keys field.

Remember that the Delay command works in milliseconds, the Wait command works in seconds.


TonyNo
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: February 16 2005 at 16:47 | IP Logged Quote onhiatus

Just in case anyone was wondering, using ph_killmacrowait (or something like that) worked like a charm. Thanks for the help!
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: March 24 2005 at 17:57 | IP Logged Quote onhiatus

Just FYI - I was haveing to many problems with the motion detector - it was just too flakey. So I simplified these further and reduced the functionality a bit.

My occupency flag no longer sets the thermostat - I do that manually. I do however let PowerHome turn down the thermostat.

New logic is something like:

Trigger: A16 On (motion detected)
- Set Occupied = 6

Timer: Every 5 minutes run:
- Occupied = Occupied - 1
- If Occupied == 0 & Thermostat is On
- - Turn thermostat off

Basically this means that 30 minutes after I leave the room PH will make sure the heater is turned down.

Besides the thermostat there are a number of timed events that only run if the Occupied counter is > 0 - this lets me do things only if I'm in the room (or have been recently)

Not quite as elegant as originally designed, but it does work reliably.
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus'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