Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: generic SEND_INSTEON Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 12 2007 at 17:55 | IP Logged Quote jeffw_00

Continued from the poorly-named thread

http://www.myx10.com/forum/forum_posts.asp?TID=1544&PN=1&TPN =2


Updated...
rev 1 used ph_getinsteonstat, which uses only what PH -thinks- the module is set to

rev 2 used ph_getinsteonlevelrt, which gets the real status, but it also used submacros (which don't suspend the calling macro if you use a wait), and global variables.

rev 3 (below) uses LOCAL9, LOCAL10 as local variables and no submacros. Also added comments, which makes it look bigger than it really is.

FWIW - this REALLY works - I have some ICON appliance modules with small loads, and there's apparently a bug in the modules that causes them to shutdown (LED goes dark) occasionally because of the low-current load. SH is supposedly asking the developers about it for me.

On a couple of other modules, I've witnessed "bounce" (turned off, and then on, because the load-sensing was enabled), and 5 seconds later, the retry turned it off.

Point is, whenever it happens, the next time a command is sent to the offending module... I GET AN EMAIL! How cool is that? I know everything's working when I don't get any Emails....

PH rocks!
/j

[updated 12/27/07, 10:54PM ET]
=======================

insert into macroheader values ('SEND_INSTEON','Generic INSTEON Sender',0,0,1);
insert into macrodetail values ('SEND_INSTEON',1,37,'',NULL,'[LOCAL1] is the id of the device. [LOCAL2] is the desired state (1=on, 0=off). [LOCAL3] is 1 if the source was a trigger, 0 if a timed event (we try harder on timed events) [LOCAL9] and [LOCAL10] used internally',0,'');
insert into macrodetail values ('SEND_INSTEON',2,36,'',NULL,'"CALLED WITH: " + ph_getvar_s(1,1) + " | " + ph_getvar_n(1,2) + " | " + ph_getvar_n(1,3) ',0,'');
insert into macrodetail values ('SEND_INSTEON',3,37,'',NULL,'First - see if the device is already in the desired state, if it is, we''re done. Otherwise, send it a command, and wait 5 seconds',0,'');
insert into macrodetail values ('SEND_INSTEON',4,37,'',NULL,'Next 3 lines check current module status, set [LOCAL10] as follows: 0=off, 1=on, 2=can''t contact module, 3 = bad module name, and exit if module status is at desired state. This 3-line code block is repeated 4 more times in this macro',0,'');
insert into macrodetail values ('SEND_INSTEON',5,38,'',0,'ph_setvar_a(1,9,ph_getinsteonleve lrt("[LOCAL1]"))',1,'');
insert into macrodetail values ('SEND_INSTEON',6,38,'',0,'ph_setvar_a(1,10,if([LOCAL9]=0,0,if([LOCAL9]>0,1,if([LOCAL9]= -2 ,2, 3))))',1,'');
insert into macrodetail values ('SEND_INSTEON',7,16,'',NULL,'if([LOCAL10]=(ph_getvar_n(1,2)),999,1)',1,'');
insert into macrodetail values ('SEND_INSTEON',8,38,'',0,'if([LOCAL2] = 0, ph_insteon( "[LOCAL1]", ifastoff, 0), ph_insteon( "[LOCAL1]", ifaston, 0))',0,'');
insert into macrodetail values ('SEND_INSTEON',9,31,'',NULL,'5',0,'');
insert into macrodetail values ('SEND_INSTEON',10,37,'',NULL,'Now see if we succeeded, if not, try again',0,'');
insert into macrodetail values ('SEND_INSTEON',11,38,'',0,'ph_setvar_a(1,9,ph_getinsteonlev elrt("[LOCAL1]"))',0,'');
insert into macrodetail values ('SEND_INSTEON',12,38,'',0,'ph_setvar_a(1,10,if([LOCAL9]=0,0,if([LOCAL9]>0,1,if([LOCAL9]= -2 ,2, 3))))',0,'');
insert into macrodetail values ('SEND_INSTEON',13,16,'',NULL,'if([LOCAL10]=(ph_getvar_n(1,2)),999,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',14,36,'',NULL,'"INSTEON RETRY: Device " + ph_getvar_s(1,1) + ", Desired State " + ph_getvar_n(1,2) + ", Trigger " + ph_getvar_n(1,3) + ", Error Type " + ph_getvar_n(1,10)',0,'');
insert into macrodetail values ('SEND_INSTEON',15,38,'',0,'if([LOCAL2] = 0, ph_insteon( "[LOCAL1]", ifastoff, 0), ph_insteon( "[LOCAL1]", ifaston, 0))',0,'');
insert into macrodetail values ('SEND_INSTEON',16,31,'',NULL,'5',0,'');
insert into macrodetail values ('SEND_INSTEON',17,38,'',0,'ph_setvar_a(1,9,ph_getinsteonlev elrt("[LOCAL1]"))',0,'');
insert into macrodetail values ('SEND_INSTEON',18,38,'',0,'ph_setvar_a(1,10,if([LOCAL9]=0,0,if([LOCAL9]>0,1,if([LOCAL9]= -2 ,2, 3))))',0,'');
insert into macrodetail values ('SEND_INSTEON',19,16,'',NULL,'if([LOCAL10]=(ph_getvar_n(1,2)),999,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',20,37,'',NULL,'If we still haven''t succeeded, but it was a trigger, one more try and then we''re done, otherwise wait 60 sec and try again',0,'');
insert into macrodetail values ('SEND_INSTEON',21,16,'',NULL,'if((ph_getvar_n(1,3)) = 1,3,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',22,31,'',NULL,'60',0,'');
insert into macrodetail values ('SEND_INSTEON',23,38,'',0,'ph_setvar_a(1,9,ph_getinsteonlev elrt("[LOCAL1]"))',0,'');
insert into macrodetail values ('SEND_INSTEON',24,38,'',0,'ph_setvar_a(1,10,if([LOCAL9]=0,0,if([LOCAL9]>0,1,if([LOCAL9]= -2 ,2, 3))))',0,'');
insert into macrodetail values ('SEND_INSTEON',25,16,'',NULL,'if([LOCAL10]=(ph_getvar_n(1,2)),999,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',26,36,'',NULL,'"INSTEON RETRY: Device " + ph_getvar_s(1,1) + ", Desired State " + ph_getvar_n(1,2) + ", Trigger " + ph_getvar_n(1,3) + ", Error Type " + ph_getvar_n(1,10)',0,'');
insert into macrodetail values ('SEND_INSTEON',27,38,'',0,'if([LOCAL2] = 0, ph_insteon( "[LOCAL1]", ifastoff, 0), ph_insteon( "[LOCAL1]", ifaston, 0))',0,'');
insert into macrodetail values ('SEND_INSTEON',28,31,'',NULL,'5',0,'');
insert into macrodetail values ('SEND_INSTEON',29,38,'',0,'ph_setvar_a(1,9,ph_getinsteonlev elrt("[LOCAL1]"))',0,'');
insert into macrodetail values ('SEND_INSTEON',30,38,'',0,'ph_setvar_a(1,10,if([LOCAL9]=0,0,if([LOCAL9]>0,1,if([LOCAL9]= -2 ,2, 3))))',0,'');
insert into macrodetail values ('SEND_INSTEON',31,16,'',NULL,'if([LOCAL10]=(ph_getvar_n(1,2)),999,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',32,37,'',NULL,'No more retries - log the error.',0,'');
insert into macrodetail values ('SEND_INSTEON',33,38,'',0,'ph_addtoglobal("IERROR",1)',0,'' );
insert into macrodetail values ('SEND_INSTEON',34,38,'',0,'ph_setccobjtext ( "MAIN", "IERROR_BUTTON", "{IERROR} INSTEON ERROR(S)" ) ',0,'');
insert into macrodetail values ('SEND_INSTEON',35,38,'',0,'ph_setccobjfcolor("MAIN","IERROR _BUTTON",rgb(255,0,0))',0,'');
insert into macrodetail values ('SEND_INSTEON',36,16,'',NULL,'if({IERROR} > 12,999,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',37,38,'',0,'ph_macroparm("SENDEMAIL","INSTEO N ERROR (count = {IERROR} ), Device [LOCAL1], Desired State [LOCAL2], Trigger [LOCAL3], Error Type [LOCAL10]",0,0,0,0)',0,'');


Edited by jeffw_00 - December 27 2007 at 22:54
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 12 2007 at 18:21 | IP Logged Quote BeachBum

Much better...

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 25 2007 at 14:22 | IP Logged Quote jeffw_00

integrated into top post

Edited by jeffw_00 - December 27 2007 at 19:50
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 27 2007 at 11:50 | IP Logged Quote jeffw_00

integrated into top post

Edited by jeffw_00 - December 27 2007 at 19:51
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: December 27 2007 at 18:36 | IP Logged Quote TonyNo

Do you try to disable local control on that module?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 27 2007 at 18:44 | IP Logged Quote jeffw_00

Hi Tony - this code works regardless of whether local-control is enabled or not.

If you're asking about my failures with ICON Appliance Modules and low-current loads, I've documented my testing here

http://www.techmall.com/topic.asp?TOPIC_ID=2356

and here

http://www.techmall.com/topic.asp?TOPIC_ID=2391

Bottom line, I have found steps (disabling local-sensing, adding resistive load) that reduce the problem, but the only thing that eliminates it is to put a lightbulb in parallel with the load. I have (I'm told) a request into the developers to find out if there is any sort of passive RLC load that can be used instead of a lightbulb.

/j




Edited by jeffw_00 - December 27 2007 at 19:51
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: February 24 2008 at 14:15 | IP Logged Quote jeffw_00

Ok, I'm embarrassed. Now that I have learned more about PH, the code I previously posted is dreadfully cumbersome. There's a much better way to do it. First, I discovered ph_insteonwithret, which not only sets a device and returns the device's status in one operation, but if it's not successful it performs 2 retries before returning. The only thing my code adds is additional retries delayed in time (in case there is a short term disruption of the powerline), and logging (so you know about every failed event). The main routine is below. Note it uses labels (rather than jumps) for easier editing, and the non-existent label "NEXTLINE" to, well, go to the next line.

insert into macroheader values ('SEND_INSTEON','Generic INSTEON Sender',0,0,1);
insert into macrodetail values ('SEND_INSTEON',1,37,'',NULL,'[LOCAL1] is the id of the device. [LOCAL2] is the desired state (1=on, 0=off). [LOCAL3] is 1 if the source was a trigger, 0 if a timed event (we try harder on timed events) [LOCAL9] used internally. ',0,'');
insert into macrodetail values ('SEND_INSTEON',2,36,'',NULL,'"CALLED WITH: " + ph_getvar_s(1,1) + " | " + ph_getvar_n(1,2) + " | " + ph_getvar_n(1,3) ',1,'');
insert into macrodetail values ('SEND_INSTEON',3,37,'',NULL,'The loop sends the command, checks status, and then decides whether to retry or error out [LOCAL7] is the retry counter',0,'');
insert into macrodetail values ('SEND_INSTEON',4,15,'[LOCAL7]',NULL,'0',0,'');
insert into macrodetail values ('SEND_INSTEON',5,26,'',NULL,'START',0,'');
insert into macrodetail values ('SEND_INSTEON',6,38,'',0,'ph_addtovar(1,7, 1 )',0,'');
insert into macrodetail values ('SEND_INSTEON',7,15,'[LOCAL9]',NULL,'ph_insteonwithret("[LOCAL1]",if (ph_getvar_n(1,2)=1,ifaston,ifastoff),0)',0,'');
insert into macrodetail values ('SEND_INSTEON',8,37,'',NULL,' if we succeeded we''re done, if not, try again',0,'');
insert into macrodetail values ('SEND_INSTEON',9,27,'',NULL,'if(ph_getvar_n(1,9)=0,"DONE",i f(ph_getvar_n(1,7)<3,"NEXTLINE","ERROR"))',0,'');
insert into macrodetail values ('SEND_INSTEON',10,15,'[LOCAL8]',NULL,'"INSTEON RETRY [LOCAL7]: Device [LOCAL1], Desired State [LOCAL2], Trigger [LOCAL3], Returned Status [LOCAL9]"',0,'');
insert into macrodetail values ('SEND_INSTEON',11,36,'',NULL,'"[LOCAL8]"',0,'');
insert into macrodetail values ('SEND_INSTEON',12,38,'',0,'ph_macroparm("LOG_ERROR","[LOCAL8]",0,0,0,1)',0,'');
insert into macrodetail values ('SEND_INSTEON',13,37,'',NULL,'if it''s 1st retry, wait a bit and try again. if 2nd retry and timed event, wait a minute and try again, otherwise error out',0,'');
insert into macrodetail values ('SEND_INSTEON',14,27,'',NULL,'if(ph_getvar_n(1,7)<2,"DEL AY",if (ph_getvar_n(1,3)=0,"NEXTLINE","ERROR"))',0,'');
insert into macrodetail values ('SEND_INSTEON',15,31,'',NULL,'23',0,'');
insert into macrodetail values ('SEND_INSTEON',16,26,'',NULL,'DELAY',0,'');
insert into macrodetail values ('SEND_INSTEON',17,31,'',NULL,'7',0,'');
insert into macrodetail values ('SEND_INSTEON',18,27,'',NULL,'"START"',0,'');
insert into macrodetail values ('SEND_INSTEON',19,37,'',NULL,'No more retries - log the error.',0,'');
insert into macrodetail values ('SEND_INSTEON',20,26,'',NULL,'ERROR',0,'');
insert into macrodetail values ('SEND_INSTEON',21,38,'',0,'ph_macroparm("LOG_ERROR", ph_getvar_s(1,1), ph_getvar_n(1,2),ph_getvar_n(1,3), ph_getvar_n(1,9),0)',0,'');
insert into macrodetail values ('SEND_INSTEON',22,26,'',NULL,'DONE',0,'');

This calls a macro "LOG_ERROR" which is shown below. It may be fancier than you need. It logs retries to a file, and in the event of an actual error, it logs, it, sends an email, and changes the color and legend on a control panel button.

insert into macroheader values ('LOG_ERROR','Log Error',0,0,1);
insert into macrodetail values ('LOG_ERROR',1,37,'',NULL,'LOCAL1=DEVICE/RETRY MSG, LOCAL2=DESIRED STATE, LOCAL3=TRIGGER, LOCAL4=STATUS, LOCAL5=RETRY',0,'');
insert into macrodetail values ('LOG_ERROR',2,16,'',NULL,'if({IERROR} > 100,999,1)',0,'');
insert into macrodetail values ('LOG_ERROR',3,38,'',0,'ph_setvar_s(1,8,string(today(),"yyyy -mm-dd hh:mm:ss.fff")) ',0,'');
insert into macrodetail values ('LOG_ERROR',4,16,'',NULL,'if(ph_getvar_n(1,5)=1,1,3)',0,'') ;
insert into macrodetail values ('LOG_ERROR',5,38,'',0,'ph_setvar_s(1,7," [LOCAL8]: [LOCAL1] " + char(13) + char(10))',0,'');
insert into macrodetail values ('LOG_ERROR',6,27,'',NULL,'"LOGGING"',0,'');
insert into macrodetail values ('LOG_ERROR',7,38,'',0,'ph_setvar_s(1,7," [LOCAL8]: INSTEON ERROR (count = {IERROR} ), Device [LOCAL1], Desired State [LOCAL2], Trigger [LOCAL3], Returned Status [LOCAL4]" + char(13) + char(10) )',0,'');
insert into macrodetail values ('LOG_ERROR',8,38,'',0,'ph_addtoglobal("IERROR",1)',0,'');
insert into macrodetail values ('LOG_ERROR',9,38,'',0,'ph_setccobjtext ( "MAIN", "IERROR_BUTTON", "{IERROR} INSTEON ERROR(S)" ) ',0,'');
insert into macrodetail values ('LOG_ERROR',10,38,'',0,'ph_setccobjfcolor("MAIN","IERROR_BU TTON",rgb(255,0,0))',0,'');
insert into macrodetail values ('LOG_ERROR',11,16,'',NULL,'if({IERROR} > 12,2,1)',0,'');
insert into macrodetail values ('LOG_ERROR',12,38,'',0,'ph_macroparm("SENDEMAIL",ph_getvar_ s(1,7),0,0,0,0)',0,'');
insert into macrodetail values ('LOG_ERROR',13,26,'',NULL,'LOGGING',0,'');
insert into macrodetail values ('LOG_ERROR',14,38,'',0,'ph_writefile("c:\jeff\insteon\error .log",0,ph_getvar_s(1,7))',0,'');

Macro SENDEMAIL is pretty simple… it uses ph_sendsmtpemail to send a message containing [LOCAL1]

Enjoy
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: March 05 2008 at 12:06 | IP Logged Quote BeachBum

jeffw_00 wrote:
Bottom line, I have found steps (disabling local-sensing, adding resistive load) that reduce the problem, but the only thing that eliminates it is to put a lightbulb in parallel with the load. I have (I'm told) a request into the developers to find out if there is any sort of passive RLC load that can be used instead of a lightbulb.




Jeff, I am having the same problem with a CRT TV. One would think it has enough of a load. I find the failure only occurs if I’m turning it on using a controller. If I have PH turn it on I don’t experience the failure. Any thoughts??



__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 05 2008 at 12:22 | IP Logged Quote jeffw_00

my problem is limited to icon on/off modules, and perhaps, older appliance modules. Unless you set up a loop that has PH turn it on/off 50 times and don't see it, you can't say PH won't cause it as well, because it's intermittent. (obviously the module can't tell if the command comes from PH or some other controller). I can also recreate the problem by turning the module on/off using the button on the module, but again, it's intermittent.

Newest revision appliance modules, iMHO 100% eliminate the problem. I've got a long post on it over at the SH INSTEON forum.
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: March 05 2008 at 12:32 | IP Logged Quote BeachBum

This is a brand new ICON ON/OFF ADAPTER Rev. 4.0. I have yet to reset it when it comes from PH but quite frequently when linked to a ControLinc. For every 1 command from ControLinc there are 2 more that follow from PH. I did read your post on SH. Keep up the good work.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 05 2008 at 13:00 | IP Logged Quote jeffw_00

swap it with a brand new appliance module. my understanding is that the icons are not getting the SW upgrade that removes the problem. However, if you explain the issue, and point out that icon -should- be able to handle it, you might get them to cover the shipping both ways
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 

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