Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: PLC triggering a macro? 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: October 23 2006 at 13:28 | IP Logged Quote nadler

I would like to trigger a particular macro when the PLC receives ANY insteon command from ANY insteon device.

What I am trying to do is run a macro which reads the status from each insteon device and then updates the control center buttons for each device. I have the macro which runs well. I have the control center buttons which get updated when the macro runs. Now I just want to run the macro automatically. I had set a trigger to run the macro every 1 minute but after running the macro every minute for 5 hours it crashed my pc. So I thought, as an alternative, I would update All the CC buttons each time a device is turned on/off at the switch. The tedious way to do this is to make a trigger for each device (actually 4 triggers for each device -on,off,faston,fastoff). That's a lot of triggers and a lot of time to make the triggers. So I thought it would be easier if I just had one trigger which executed the macro every time a device was manually changed. Since the PLC gets this information, this should be a piece of cake. For some reason, I can't figure out how to do this. Any suggestions appreciated.

P.S. if anyone would like the code to change the color and status of CC toggle buttons (ON/OFF is one button not two) or the macro to check the status of the insteon devices, just let me know and I will post the code.
Back to Top View nadler's Profile Search for other posts by nadler
 
cmhardwick
Senior Member
Senior Member
Avatar

Joined: July 08 2006
Location: United States
Online Status: Offline
Posts: 290
Posted: October 23 2006 at 13:34 | IP Logged Quote cmhardwick

I believe this type of trigger is in the next update.

__________________
Cicero, Enjoying automation!
Back to Top View cmhardwick's Profile Search for other posts by cmhardwick Visit cmhardwick's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: October 23 2006 at 21:34 | IP Logged Quote smarty

Nadler,
Please post your macro, I would like to see it.

While I am not using the PH CC for button displays (I am using Xlobby), I like the idea of always keeping in sink.

Besides, seeing new code sometimes leads to other neat ideas.



__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: October 24 2006 at 16:54 | IP Logged Quote dhoward

Noel,

This trigger will now be in the next version. It originally required you to declare the Insteon device whose status may be changing (but you could use ANY for button and ANY for command) but I just went ahead and made changes so that you can specify ANY for the Insteon Device as well.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
crisx
Groupie
Groupie
Avatar

Joined: September 14 2006
Location: United States
Online Status: Offline
Posts: 72
Posted: October 24 2006 at 20:30 | IP Logged Quote crisx

With this new trigger, will there be a way to identify the last Insteon command received? Or does this exist already? Say the trigger activates anytime a light is turned on from an insteon switch. Will there be a way to identify which light was turned on? A ph_lastinsteon or something similar? Seems this would be very useful / almost necessary to have with the new trigger.

I briefly looked to see if this already exists, but couldn't find anything.

Thanks,

Cris

Back to Top View crisx's Profile Search for other posts by crisx
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: October 24 2006 at 20:55 | IP Logged Quote dhoward

Cris,

There isnt a function that tells what the last Insteon command was. However, this information will be readily available from within the trigger contained in the [TEMP] variables. You'll be able to access the address and ID of the affected device, the command itself, and the address of the sending device.

When a trigger fires, certain TEMP variables are always populated with data and depending upon the trigger type, additional data will be in other TEMP variables. You can also use these TEMP variables in the BOOLEAN column to further refine whether the trigger fires or not.

I don't have any good documentation on what data is in which TEMP's in which trigger types but I can answer any specifics you may be interested in. Another thing to do is have the trigger call a macro and then have the macro show a Message Box command displaying all 10 TEMP variables.

HTH,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: October 24 2006 at 21:02 | IP Logged Quote nadler

Dave,
Thanks for incorporating the trigger for the PLC. That will go along way in my implimentation of HA!
Back to Top View nadler's Profile Search for other posts by nadler
 
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: October 24 2006 at 22:00 | IP Logged Quote nadler

CONTROL CENTER BUTTON STATUS

Until the latest version of PH, I hadn’t been using the Control Center at all. I found it awkward to use. In the latest version of PH setting up buttons in the Control Center is much easier. Now I can control everything in the house (Insteon, X-10, IR, RS-232) using the buttons in the Control Center without any other front end software and without any programming (other than PH macros).

The first thing I wanted to do was make each button in the Control Center a toggle button - one button to press which would turn a device on or off. My initial CC attempt was making two buttons per device. One button for On and another button for off. This proved a waste of screen space, a little confusing and I wound up writing a macro to change the color of each button and its reciprocal every time the button was pressed. This was just silly. Since it required a macro to change colors anyway I thought I would try my hand at a one button solution that would toggle one button On/Off and change color.

Here is the result:

insert into macroheader values ('CONTROL CENTER BUTTON TOG','TURNS ON/OFF DEVICE & BUT',0,0,1);
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',1,37,'',NULL,'Get the insteon status of the device you want to control (i.e. is it on or off?. If it''s off go to the next line. If it''s on jump 4 lines and turn it off.',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',2,16,'',NULL,'if (ph_getinsteonstat("YOUR DEVICE NAME")=1,1,4)',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',3,32,'YOUR DEVICE NAME',17,'',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',4,37,'',NULL,'You just turned the device on. Now change the color of the button in the Control Center to Green.',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',5,38,'',NULL,'ph_setccobjbcolor("MY HOUSE","YOURBUTTONNAMEINTHECC",rgb(0,255, 0 ))',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',6,16,'',NULL,'999',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',7,16,'',NULL,'if (ph_getinsteonstat("YOUR DEVICE NAME")=2,1,999)',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',8,32,'YOUR DEVICE NAME',19,'',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',9,37,'',NULL,'You''ve just turned the device off. Now change the color of the devices''s CC button to Yellow.',0,'');
insert into macrodetail values ('CONTROL CENTER BUTTON TOG',10,38,'',NULL,'ph_setccobjbcolor("MY HOUSE","YOURBUTTONNAMEINTHECC",rgb(255, 255, 0 ))',0,'');

1. The macro is called when the button is pressed in the control center.
2. The macro checks the insteon status of the device. If the device is on, it turns the device off and vica versa..
3. The macro changes the color of the control center button to reflect the new status of the device.

I then needed a way to reflect the correct status of each device and thus each control center button when I opened up the control center for the first time and any subsequent time. I wrote a macro that runs when the control center starts. To set a startup macro for the control center go to the Powerhome Explorer/Setup/ControlCenter – it has a place to put in the name of a startup macro.

The macro that’s run on control center startup is pretty straight forward. It runs a formula for each insteon device to check the device’s status and then change the button color accordingly. This is the formula I used. I copied it repeatedly and changed the device and button name for each device in my setup.

if (ph_getinsteonstat( "YOURDEVICENAME")=2,ph_setccobjbcolor("YOUR CONTROL CENTER TAB NAME","YOUR CONTROL CENTER BUTTON NAME",rgb(0, 255, 0 )),ph_setccobjbcolor("YOUR CONTROL CENTER TAB NAME "," YOUR CONTROL CENTER BUTTON NAME ",rgb(255, 255, 0 )))

The last problem was to have the buttons change if an insteon device was manually switched on or off at the switch.
There were two ways I considered. One was to run the formula above constantly (I guess it’s the same thing as polling the devices only with a button color change as the result). To do this I set a trigger to run the macro that contained all the formulas for all my devices every minute. After 5 hours of running the macro every minute, my computer crashed. So I gave up that idea. I then decided that I would run the macro with the formulas every time the PLC received an on or off from any insteon device. To do this I needed a trigger that would trigger the formula macro each time each device was turned on or off at the switch. This required at least 2 triggers for each device (four triggers for each device if you wanted to catch fast on/fast off also). That’s a lot of triggers!
However a trigger for every device will no longer be necessary as Dave has just incorporated a PLC trigger into the next version of PH. So any time the PLC receives a command it can fire a trigger that executes a macro. Thus checking the status of the insteon switches will henceforth require only 1 trigger instead of up to 4 for each device.

Now, as you can tell, I’m not a programmer, just an end user who likes to tinker. So there are probably at least 10 better and simpler ways to do this. Feel free to chime right in and post improvements!
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