Author |
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: March 02 2009 at 01:59 | IP Logged
|
|
|
hi all,
have not posted for some time but been here all the time reading....
I have the following questions for ideas:
I need a macro that toggles on/off on X10
if the status is off the command sent must be on and reverse.... I've already got it working but maybe you have some ideas to make it more beautifull...
Peter
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: March 02 2009 at 08:46 | IP Logged
|
|
|
This is a method I used for error recovery and it worked for me but it requires one to set 2 Globals. One with an X10 device and the other the Level of that device when an X10 command was sent. I used this to recover all my X10 devices after a power failure or I visually detected some lighting issues. This could easily be modified to toggle the X10 device in question. Though I don’t know if it makes it "more beautiful".
IF (PH_GETGLOBAL_N(PH_GETGLOBAL_S("X10LEVEL_GLOBAL")) = 0, PH_X10BTN(PH_GETGLOBAL_S("X10_GLOBAL"), XOFF, 0), PH_X10BTN(PH_GETGLOBAL_S("X10_GLOBAL"), XOFF, 0) + PH_X10BTN(PH_GETGLOBAL_S("X10_GLOBAL"), XON, 0) + PH_X10BTN(PH_GETGLOBAL_S("X10_GLOBAL"), XDIM, PH_GETGLOBAL_N(PH_GETGLOBAL_S("X10LEVEL_GLOBAL"))))
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: March 10 2009 at 04:47 | IP Logged
|
|
|
been away for a time sorry for that but my work as a union-representative forces me to now, I now have to prevent 53-workers from being fired....
I am going to give it a try BeachBum but can't say when I've got the time again since most of my days are spent in court and at the mainoffice in Weert getting this firingplan off the table.
so I'd have to add 2 globals:
X10_Global and X10level and that's it?
Peter
Edited by krommetje - March 10 2009 at 04:51
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: March 10 2009 at 08:51 | IP Logged
|
|
|
The level global is loaded in a routine from a group of all the devices I want to test. I have a global for each devices desired level. When I make a change to a device level I update its level global. In the macro I loop thought the group until I run out the bottom. This is an example of the global set:
PH_SETGLOBAL_S("X10_GLOBAL", "GBR_DRESSER") + PH_SETGLOBAL_S("X10LEVEL_GLOBAL", "X10LEVEL_GBR_DRESSER")
X10_GLOBAL is SET directly whereas X10LEVEL_GLOBAL is SET from a global for the level of that device. The end result is each device is reset to its intended level. If in a macro I am dealing with only one device then I modify the IF statement so I don’t do a double Getglobal. Good luck with your negotiations..
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: March 24 2009 at 09:23 | IP Logged
|
|
|
Negotiations going OK... thanks, originally I have this macro checking if the shutters are open or closed and if any errors are there...
Code:
insert into macroheader values ('RFIDDOOR','RFIDDOOR',0,0,1);
insert into macrodetail values ('RFIDDOOR',1,38,'',0,'case([X10STATK4] when 2 then Case({ROLVOOR} when 1 then
ph_macro("VOORDEURROLLUIK DICHT")))',0,'');
insert into macrodetail values ('RFIDDOOR',2,38,'',0,'case([X10STATK4] when 1 then Case({ROLVOOR} when 2 then
ph_macro("VOORDEURROLLUIK DICHT")))',0,'');
insert into macrodetail values ('RFIDDOOR',3,38,'',0,'case([X10STATK4] when 2 then Case({ROLVOOR} when 2 then
ph_macro("VOORDEURROLLUIK DICHT") else case([X10STATK4] when 1 then Case({ROLVOOR} when 1 then ph_macro("VOORDEURROLLUIK OPEN")))))',0,'');
|
|
|
If the shutters are being closed, a GV is set and checked when an RFID-Check is done...
The same when shutters being opened...
both GV and status have to be the same for an action to be taken....
if these are not the same, then the shutter is closed first...
Edited by krommetje - March 24 2009 at 09:56
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 10 2009 at 12:23 | IP Logged
|
|
|
What was I thinking!!!
it's better and cleaner to do just this:
Code:
insert into macroheader values ('RFIDDOOR','RFIDDOOR',0,0,1);
insert into macrodetail values ('RFIDDOOR',1,38,'',0,'[X10STATK4]+{ROLVOOR}',0,'');
insert into macrodetail values ('RFIDDOOR',2,38,'',0,'IF([X10STATK4]+{ROLVOOR}=3,PH_MACRO("VOORDEURROLLUIK DICHT"),0)',0,'');
insert into macrodetail values ('RFIDDOOR',3,38,'',0,'IF ([X10STATK4]+{ROLVOOR}=2, PH_MACRO("VOORDEURROLLUIK OPEN"),0)',0,'');
insert into macrodetail values ('RFIDDOOR',4,38,'',0,'IF ([X10STATK4]+{ROLVOOR}=4, PH_MACRO("VOORDEURROLLUIK DICHT"),0)',0,'');
|
|
|
instead of checking a status and a gv, I can add the to together and check the result of the adding...
less code...
peter
|
Back to Top |
|
|
|
|