| krommetje Super User
 
  
  
 Joined: December 29 2004
 Location: Netherlands
 Online Status: Offline
 Posts: 695
 | 
          Hey guys,
           | Posted: May 31 2010 at 10:59 | IP Logged |   |  
           | 
 |  
 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
 |