Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Macros, Scripts, and Formulas Repository
 PowerHome Messageboard : PowerHome Macros, Scripts, and Formulas Repository
Subject Topic: timer and switch Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jostim
Groupie
Groupie
Avatar

Joined: February 12 2007
Location: United States
Online Status: Offline
Posts: 45
Posted: February 16 2007 at 05:02 | IP Logged Quote jostim

I am new with PH, so this could probably be programmed much more elegantly.

I have a few rooms in the house where I like to use an IR sensor, so the light turns on when someone enters. I use a few old Activehome PIR wireless sensors. They send an X10 signal that activates a macro that turns on the lights (via Icon dimmer switches). After a while the lights turn off again. When I use the switch to turn on the lights, the lights stay on.

I use PH version 1.03.4.9
You'll need the following Global Variables:
GRDRB_DIM_STEPS    this is the number of steps the lights dim before they turn off.
GRDRB_ON_LEVEL    the dim-level
GRDRB_SWITCH      indicates if the switch has been used
GRDRB_TIME        the time before the lights start to dim (multiply by 5 seconds)
GRDRB_TMP        a temporary GV

there are four individual macro's (I said I was new at this)

the first one (GRDRB START) is triggered by the PIR sensor

insert into macroheader values ('GRDRB START','GARDEROBE LIGHTS',0,0,1);
insert into macrodetail values ('GRDRB START',1,10,'GRDRB_TMP',NULL,'{GRDRB_TIME}',0,'');
insert into macrodetail values ('GRDRB START',2,27,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON","END","CONT")',0,'');
insert into macrodetail values ('GRDRB START',3,26,'',NULL,'CONT',0,'');
insert into macrodetail values ('GRDRB START',4,27,'',NULL,'if(ph_getglobal_s ("GRDRB_TRIGGER") = "BUSY","END","MACRO")',0,'');
insert into macrodetail values ('GRDRB START',5,26,'',NULL,'MACRO',0,'');
insert into macrodetail values ('GRDRB START',6,1,'GRDRB TIMER',0,'',0,'');
insert into macrodetail values ('GRDRB START',7,26,'',NULL,'END',0,'');

the second one (GRDRB TIMER) is activated by GRDRB START

insert into macroheader values ('GRDRB TIMER','GARDEROBE LIGHTS',0,0,0);
insert into macrodetail values ('GRDRB TIMER',1,26,'',NULL,'START',0,'');
insert into macrodetail values ('GRDRB TIMER',2,27,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON","SWITCH","CONT1")',0,'');
insert into macrodetail values ('GRDRB TIMER',3,26,'',NULL,'CONT1',0,'');
insert into macrodetail values ('GRDRB TIMER',4,10,'GRDRB_TRIGGER',NULL,'"BUSY"',0,'');
insert into macrodetail values ('GRDRB TIMER',5,10,'GRDRB_TMP',NULL,'{GRDRB_TIME}',0,'');
insert into macrodetail values ('GRDRB TIMER',6,32,'GARDEROBE',17,'{GRDRB_ON_LEVEL}',0,'');
insert into macrodetail values ('GRDRB TIMER',7,26,'',NULL,'TIMER',0,'');
insert into macrodetail values ('GRDRB TIMER',8,31,'',NULL,'5',0,'');
insert into macrodetail values ('GRDRB TIMER',9,27,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON","SWITCH","CONT2")',0,'');
insert into macrodetail values ('GRDRB TIMER',10,26,'',NULL,'CONT2',0,'');
insert into macrodetail values ('GRDRB TIMER',11,15,'[LOCAL3]',NULL,'{GRDRB_TMP}-1',0,'');
insert into macrodetail values ('GRDRB TIMER',12,10,'GRDRB_TMP',NULL,'[LOCAL3]',0,'');
insert into macrodetail values ('GRDRB TIMER',13,27,'',NULL,'if(ph_getglobal_n("GRDRB_TMP")<=0," CONT3","TIMER")',0,'');
insert into macrodetail values ('GRDRB TIMER',14,26,'',NULL,'CONT3',0,'');
insert into macrodetail values ('GRDRB TIMER',15,15,'[LOCAL3]',NULL,'{GRDRB_DIM_STEPS}',0,'');
insert into macrodetail values ('GRDRB TIMER',16,27,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON","SWITCH","DIMMER")',0,'');
insert into macrodetail values ('GRDRB TIMER',17,26,'',NULL,'DIMMER',0,'');
insert into macrodetail values ('GRDRB TIMER',18,37,'',NULL,'***************DIMMER**************',0 ,'');
insert into macrodetail values ('GRDRB TIMER',19,31,'',NULL,'3',0,'');
insert into macrodetail values ('GRDRB TIMER',20,15,'[LOCAL4]',NULL,'[LOCAL3]-1',0,'');
insert into macrodetail values ('GRDRB TIMER',21,15,'[LOCAL3]',NULL,'[LOCAL4]',0,'');
insert into macrodetail values ('GRDRB TIMER',22,32,'GARDEROBE',22,'',0,'');
insert into macrodetail values ('GRDRB TIMER',23,32,'GARDEROBE',22,'',0,'');
insert into macrodetail values ('GRDRB TIMER',24,32,'GARDEROBE',22,'',0,'');
insert into macrodetail values ('GRDRB TIMER',25,32,'GARDEROBE',22,'',0,'');
insert into macrodetail values ('GRDRB TIMER',26,27,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON","SWITCH","CONT4")',0,'');
insert into macrodetail values ('GRDRB TIMER',27,26,'',NULL,'CONT4',0,'');
insert into macrodetail values ('GRDRB TIMER',28,27,'',NULL,'if(ph_getglobal_n("GRDRB_TMP")<=0," CONT5","START")',0,'');
insert into macrodetail values ('GRDRB TIMER',29,37,'',NULL,'ABOVE LINE IS FOR RESET OF TIMER BECAUSE OF RENEWED TRIGGER',0,'');
insert into macrodetail values ('GRDRB TIMER',30,26,'',NULL,'CONT5',0,'');
insert into macrodetail values ('GRDRB TIMER',31,27,'',NULL,'if(ph_getVAR_n(1,3)<=0,"CONT6","DIM MER")',0,'');
insert into macrodetail values ('GRDRB TIMER',32,26,'',NULL,'CONT6',0,'');
insert into macrodetail values ('GRDRB TIMER',33,32,'GARDEROBE',19,'',0,'');
insert into macrodetail values ('GRDRB TIMER',34,10,'GRDRB_TRIGGER',NULL,'"IDLE"',0,'');
insert into macrodetail values ('GRDRB TIMER',35,39,'',NULL,'',0,'');
insert into macrodetail values ('GRDRB TIMER',36,26,'',NULL,'SWITCH',0,'');
insert into macrodetail values ('GRDRB TIMER',37,32,'GARDEROBE',17,'{GRDRB_ON_LEVEL}',0,'');
insert into macrodetail values ('GRDRB TIMER',38,10,'GRDRB_TRIGGER',NULL,'"IDLE"',0,'');

this one (GRDRB SWITCH ON) is triggered by turning the switch on


insert into macroheader values ('GRDRB SWITCH ON','SWITCH ON',0,0,0);
insert into macrodetail values ('GRDRB SWITCH ON',1,16,'',NULL,'if(ph_getglobal_s ("GRDRB_SWITCH") = "ON",99,1)',0,'');
insert into macrodetail values ('GRDRB SWITCH ON',2,32,'GARDEROBE',17,'{GRDRB_ON_LEVEL}',0,'');
insert into macrodetail values ('GRDRB SWITCH ON',3,10,'GRDRB_SWITCH',NULL,'"ON"',0,'');
insert into macrodetail values ('GRDRB SWITCH ON',4,10,'GRDRB_TRIGGER',NULL,'"IDLE"',0,'');
insert into macrodetail values ('GRDRB SWITCH ON',5,10,'GRDRB_TIMER',NULL,'{GRDRB_TIME_FIXED}',0,'');

and this one (GRDRB SWITCH OFF) is triggered by turning the switch off:

insert into macroheader values ('GRDRB SWITCH OFF','GARDEROBE SWITCH OFF',0,0,0);
insert into macrodetail values ('GRDRB SWITCH OFF',1,10,'GRDRB_SWITCH',NULL,'"OFF"',0,'');
insert into macrodetail values ('GRDRB SWITCH OFF',2,10,'GRDRB_TRIGGER',NULL,'"IDLE"',0,'');

hope it works for you.



__________________
- jos
Back to Top View jostim's Profile Search for other posts by jostim
 

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