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: Automate Control Cntr Creation Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: November 04 2007 at 16:31 | IP Logged Quote nadler

WHAT DOES THIS MACRO DO?

It automatically generates a new Control Center tab.
It then automatically generates an ON and an Off Button for each of
your insteon devices.

WHO IS THIS MACRO FOR?

New PowerHome users who want to see the Control Center in action,
but don't want to take the time (yet) to make their own Control Center.
It's a good learning example.

If you are an experienced PH user I hope you will take a look at
this macro too and improve upon it. I'm not a programmer, just an enthusiastic
PH user. I realize there is much that can be done to this macro to
make it better.

HOW DOES IT WORK?

The macro first reads the cctabs database table to see how many tabs are
in the table. It then adds a new tab, giving it a unique name.

Next, the insteondevices table is read. The macro looks for either Insteon
Switchlinc dimmers, Icon dimmers or 3 prong Insteon Appliance modules.
It does NOT look for KPLs, relays or other Insteon modules. Nor does it
look for X-10 modules. (Note: You could change the macro to look for the other modules).

Lastly, the ccbuttons table is read and then updated by creating 2 separate
buttons for each device found. Each button is labled with the device's name
(to the extent the name fits on the button). The green buttons are on and
the grey buttons are the off buttons.

INSTALLATION

1. Copy the code below.
2. Paste the code you just copied into the PowerHome Multi-Editor. If you
haven't used the Multi-Editor before here is how to use.
a. Open PowerHome.
b. Click on Maintenance menu item on the top row.
c. Click on Multi-Editor.
d. A screen pops up. It should say "Script Editor (SQL)". If it doesn't
    press the Shift and the F5 key to bring it up. (Note: since this is a
    Multi-Editor by pressing the shift key and other function keys you
    can edit other types of code.)
e. Paste the code you just copied into the Script Editor.
f. Click on the Edit menu item on the top row.
g. Click on "Execute Script". You will get a message in the lower
    portion of the box that the macro has been successfully created.
    (NOTE: If you try to execute the script a second time you will get
    an error message because the macro name is already taken. If you want
    to run the script again you first have to delete the macro that was
    just created.)
3. If all went well, you've just created the macro called "CREATE CONTROL CTR".
4. You now want to run this new macro once. (You actually can run the
    macro as many times as you want. It will create a new tab with new buttons
    each time it is run).
5. Open the PowerHome Explorer (Either click on the E on the toolbar or
    click on Maintenace and then "PowerHome Explorer".
6. Click on Macros and find the "CREATE CONTROL CTR" macro. Click on the
    macro to open it.
7. Right click anywhere on the macro to open a pop up list of choices.
8. Click on PLAY from the list.

Now, open the Control Center and the newly created tab with the newly
created buttons should appear.

CODE

insert into macroheader values ('CREATE CONTROL CTR','Create Control Center',0,0,1);
insert into macrodetail values ('CREATE CONTROL CTR',1,37,'',NULL,'Reads numb of rows from cctabs table',1,'');
insert into macrodetail values ('CREATE CONTROL CTR',2,38,'',0,'ph_sqlselect(2,"select id from cctabs") ',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',3,15,'[LOCAL3]',NULL,'ph_getsqlrows(2)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',4,37,'',NULL,'Adds 1 to Local3 the number of rows in cctabs table',1,'');
insert into macrodetail values ('CREATE CONTROL CTR',5,38,'',0,'ph_addtovar(1,3,1)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',6,37,'',NULL,'Inserts a new tab into cctabs as the last tab
Names it Control_CenterX',1,'');
insert into macrodetail values ('CREATE CONTROL CTR',7,15,'[LOCAL4]',NULL,'"Control_Center"+"[LOCAL3]"',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',8,38,'',0,'ph_sqlselect(2,"INSERT INTO cctabs (Id, Tab_Order, Bkgrnd_Color, H_Scrollbar,V_Scrollbar,Bmp_Width, Bmp_Height) VALUES (''[LOCAL4]'',''[LOCAL3]'',''16711935'',''Y'',''Y'',''0'',''0'')")',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',9,37,'',NULL,'Reads numb of rows in insteondevices table where typeid=6 (insteon dimmer) and assignes it to LOCAL1',1,'');
insert into macrodetail values ('CREATE CONTROL CTR',10,38,'',0,'ph_sqlselect(1,"select id from insteondevices where Typeid IN (''4'',''6'',''10'')") ',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',11,15,'[LOCAL1]',NULL,'ph_getsqlrows(1)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',12,37,'',NULL,'Loop through each insteon device decreasing until 0 no more devices',1,'');
insert into macrodetail values ('CREATE CONTROL CTR',13,15,'[LOCAL6]',NULL,'44',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',14,15,'[LOCAL7]',NULL,'44',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',15,26,'',NULL,'MAINLOOP',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',16,15,'[LOCAL2]',NULL,'ph_getdata(1,[LOCAL1],1) ',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',17,16,'',NULL,'if(ph_getvar_n(1,1)>0,1,13)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',18,38,'',0,'ph_addtovar(1,1,(-1))',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',19,38,'',0,'ph_sqlselect(3,"select * from ccbuttons") ',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',20,15,'[LOCAL5]',NULL,'ph_getsqlrows(3)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',21,38,'',0,'ph_sqlselect(3,"INSERT INTO ccbuttons (tab_id, sequence,button_type,button_key1,button_key2,key_desc,key_x, key_y,key_width,key_height,key_code,key_flag,key_text,key_bk grnd,key_border,fontface,fontsize,fontweight,fontitalic,font uline,fontalign,itemtype,filepath_up,filepath_down,brush_hat ch,pen_color,pen_style,pen_width,ellipse_height,ellipse_widt h,id) VALUES (''[LOCAL4]'',''4'',''5'',''ph_insteon(~"[LOCAL2]~",ion,255)'','' '',''[LOCAL2]'',''[LOCAL6]'',''[LOCAL7] '',''252'',''96'',''0'',''0'',''0'',''65280'',''10'',''Arial '',''7'',''400'',''0'',''0'',''2'',''0'','' '','' '',''6'',''0'',''0'',''1'',''50'',''50'',''[LOCAL6][LOCAL7]'')")',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',22,15,'[LOCAL8]',NULL,'"[LOCAL7]"',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',23,15,'[LOCAL8]',NULL,'ph_addtovar(1,8,120)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',24,38,'',0,'ph_sqlselect(3,"INSERT INTO ccbuttons (tab_id, sequence,button_type,button_key1,button_key2,key_desc,key_x, key_y,key_width,key_height,key_code,key_flag,key_text,key_bk grnd,key_border,fontface,fontsize,fontweight,fontitalic,font uline,fontalign,itemtype,filepath_up,filepath_down,brush_hat ch,pen_color,pen_style,pen_width,ellipse_height,ellipse_widt h,id) VALUES (''[LOCAL4]'',''4'',''5'',''ph_insteon(~"[LOCAL2]~",ioff,0)'','' '',''[LOCAL2]'',''[LOCAL6]'',''[LOCAL8] '',''252'',''96'',''0'',''0'',''0'',''12632256'',''10'',''Ar ial'',''7'',''400'',''0'',''0'',''2'',''0'','' '','' '',''6'',''0'',''0'',''1'',''50'',''50'',''[LOCAL6][LOCAL7]a'')")',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',25,38,'',0,'ph_addtovar(1,6,400)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',26,16,'',NULL,'if(ph_getvar_n(1,6)>2200,1,3)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',27,15,'[LOCAL6]',NULL,'45',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',28,38,'',0,'ph_addtovar(1,7,400)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',29,27,'',NULL,'"MAINLOOP"',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',30,38,'',1,'ph_sqldestroy(3)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',31,38,'',0,'ph_sqldestroy(1)',0,'');
insert into macrodetail values ('CREATE CONTROL CTR',32,38,'',0,'ph_sqldestroy(2)',0,'');
Back to Top View nadler's Profile Search for other posts by nadler
 

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