Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: checking sensors, then create Timed event Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: May 31 2010 at 10:59 | IP Logged Quote krommetje

Hey guys,

been working on a macro which checks if the PIR-sensor in the livingroom has not detected any movement for a periode of time, the checks if a timed event has been create already (with a global, 0 for not created, 1 for created already) and if not, creates a timed event 30 minutes into the future, then writes a 1 to the same global to signal the next run of the macro that the TE has been created...

what I've got thus far:
Code:

insert into macroheader values ('MODE_LUIKEN','MODE_LUIKEN',0,0,1);
insert into macrodetail values ('MODE_LUIKEN',1,27,'',NULL,'if(HOUR(NOW())>= 22 OR NOW() < RELATIVETIME(00:00:00, [SUNRISE]),"CONTINUE","ENDMACRO") ',0,'');
insert into macrodetail values ('MODE_LUIKEN',2,26,'',NULL,'ENDMACRO',0,'');
insert into macrodetail values ('MODE_LUIKEN',3,36,'',NULL,'"No Action: Daytime"',0,'');
insert into macrodetail values ('MODE_LUIKEN',4,39,'',NULL,'',0,'');
insert into macrodetail values ('MODE_LUIKEN',5,26,'',NULL,'CONTINUE',0,'');
insert into macrodetail values ('MODE_LUIKEN',6,27,'',NULL,'IF( {TECREATED} = 1, "ENDMACRO","CREATETE")',0,'');
insert into macrodetail values ('MODE_LUIKEN',7,26,'',NULL,'CREATETE',0,'');
insert into macrodetail values ('MODE_LUIKEN',8,0,'',NULL,'',1,'');
insert into macrodetail values ('MODE_LUIKEN',9,38,'',0,'case(round(ph_minutesafter(ph_getx 10dt("I3"),today()),1)when is > 120 then ph_createtimedevent(0,"VOORDEURROLLUIK DICHT",ph_relativedatetime(today(),30)))',0,'');
insert into macrodetail values ('MODE_LUIKEN',10,10,'TECREATED',NULL,'1',0,'');
insert into macrodetail values ('MODE_LUIKEN',11,39,'',NULL,'',0,'');


All you code wizards out there? Could this work and
any advice on cleaning up the code or make it better?

Peter

Edited by krommetje - May 31 2010 at 11:00
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
sjvonstein
Groupie
Groupie


Joined: February 05 2010
Location: United States
Online Status: Offline
Posts: 75
Posted: May 31 2010 at 12:02 | IP Logged Quote sjvonstein

The only problem I see is the reset of the global variable back to "0". This could be an "if,then" statement that checks to see if it is 1 at time intervals, and if it is 1, wait "x" amount of time, then change it to "0".
Back to Top View sjvonstein's Profile Search for other posts by sjvonstein
 

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