guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: February 17 2007 at 16:37 | IP Logged
|
|
|
Here is the details of the setup for using a security door/window sensor to track the number of occupants in a room and to turn off all lights once there is nobody in the room.
See this for details of the sensor mods.
This first part is borrowed from Dave.
First, create a trigger that fires on "X10 RF In Ext" with trigger ID and Number of "(Any)" and "Any Command".
Guerrand wrote:
Optionally you can set it to only the open command, on mine that is 4 but might be different on yours. That way it only records the open triggers and you can keep your trigger sequence short. |
|
|
Have this triggers action be a "Raw Formula" with the following formula:
Code:
ph_setglobal_s("MULTIEXT",string([TEMP3],"000") + string([TEMP4],"000") + left("{MULTIEXT}",114))
|
|
|
Next create a global variable called "MULTIEXT". Set the initial value to 120 0's (000000 repeated 20 times).
guerrand wrote:
I have mine set to reset the multiext to 0 after each cycle since I don't need to keep the variables around after the count is updated. |
|
|
The global variable MULTIEXT is your incoming extended queue. The trigger updates this queue with each incoming extended command. Incoming extended command are in the format of unit (0 to 255) and command (0 to 255). So if unit 145 send a command of 32, the trigger would update the MULTIEXT queue with an entry of 145032. Each incoming multi-ext command is 6 characters long and the queue holds the most recent 20 entries. The newest entries are at the beginning with the older entries at the end.
You can even make this more familiar by creating a macro to simulate the standard ph_multix function. Do this be creating a macro called "MULTIEXT". Create a single line of command type "Set System" with ID of "[LOCAL1]". Set the formula to:
Code:
mid("{MULTIEXT}",(LOCAL1] * 6 - 5,[LOCAL2] * 6)
|
|
|
Thats it. Call the macro using the ph_macroparmret function and it will work just like the ph_multix function. For example, if you want a string of the last two multi-ext commands, use the following syntax:
Code:
ph_macroparmret("MULTIEXT",1,2,0,0,0)
|
|
|
This will return a string of 12 characters in the format detailed above.
Heres the details for the macro that does the action with the information above. It is in importable format for easy setup. Just change the variable names and labels for the units to match yours. You'll obviously need to make a global variable for tracking the number of occupants.
Code:
insert into macroheader values ('MULTIEXTLIGHTS','MULTIEXTLIGHTS',0,0,1);
insert into macrodetail values ('MULTIEXTLIGHTS',2,27,'',NULL,'ph_macroparmret("MULTIEXT",1 ,2,0,0,0)',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',4,26,'',NULL,'059004033004',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',6,27,'',NULL,'''count''',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',8,10,'JIMROOMCOUNT',NULL,'{JIMROOMCOUNT}-1 ',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',1,31,'',NULL,'2',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',3,27,'',NULL,'''end''',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',5,10,'JIMROOMCOUNT',NULL,'{JIMROOMCOUNT}+1 ',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',7,26,'',NULL,'033004059004',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',9,26,'',NULL,'count',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',10,10,'MULTIEXT',NULL,'0',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',11,38,'',0,'if({JIMROOMCOUNT}>0,ph_macr o(''bedroommotion''),ph_macro(''leavinghome''))',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',12,27,'',NULL,'''end''',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',13,27,'',NULL,'if({JIMROOMCOUNT}<0,''re set'',''end'')',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',14,26,'',NULL,'end',0,'');
insert into macrodetail values ('MULTIEXTLIGHTS',15,39,'',NULL,'',0,'');
|
|
|
Any questions you can pm me.
Edited by guerrand - February 17 2007 at 16:45
__________________ VuMe
|