Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Problem with Trigger Check Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 20 2009 at 20:00 | IP Logged Quote Handman

I swear this function was working in the past but is no longer working and I can't figure out why. I have triggers that are activated by OFF signals from X10 motion sensors. The action is a raw formula which is supposed to turn room lights off:

ph_insteon ("East Light",ioff,0) + ph_insteon ("West Light",ioff,0)

There is an IF function in the Boolean field which checks to make sure one of the two lights is actually on before sending OFF signals (to minimize the unnecessary Insteon traffic). In this case the Boolean field is:

IF (ph_getinsteonlevelrt ("East Light") >0 OR ph_getinsteonlevelrt ("West Light") >0, 1, 0)

When I check the Boolean function it returns a "1" if any of the lights is on, and a "0" if the lights are off. When I check the action function (raw formula), the lights are commanded off. The problem is that when left to do this on its own, the trigger check fires, but the raw formula never turns the lights off. All the quotation marks are correct and nothing is misspelled. What am I doing wrong?

Edited by Handman - June 21 2009 at 14:18
Back to Top View Handman's Profile Search for other posts by Handman
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 21 2009 at 13:01 | IP Logged Quote grif091

When the trigger is fired, see if the Insteon Raw Log is showing something similar to this. The device addresses will not be the same but do you see 6 TX lines all clustered together?

2009-06-21 12:44:04.562     TX 02 62 04 90 07 05 19 00
2009-06-21 12:44:09.562     TX 02 62 04 90 07 05 19 00
2009-06-21 12:44:14.562     TX 02 62 04 90 07 05 19 00
2009-06-21 12:44:19.562     TX 02 62 04 56 50 05 19 00
2009-06-21 12:44:24.562     TX 02 62 04 56 50 05 19 00
2009-06-21 12:44:29.562     TX 02 62 04 56 50 05 19 00


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 21 2009 at 13:10 | IP Logged Quote grif091

Try putting single quotes around the formula in the Boolean field. Has to be single quotes as double quotes appear in the two statements

'IF (ph_getinsteonlevelrt ("WINE BOTTLE LAMPLINC") >0 OR ph_getinsteonlevelrt ("ICON SWITCH TEST") >0, 1, 0)'

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 21 2009 at 13:23 | IP Logged Quote Handman

Lee, the trigger is checked at 10:14:56, but then no Insteon actions are fired (as if the Boolean was false). Here is the raw log below with a few surrounding events. Only five TXs, not six. Will check the single quotes next . . .

2009-06-21 10:14:55.578     RX  &nbs p;  RECEIVEX10RAW=1E 00
2009-06-21 10:14:56.109     RX  &nbs p;  RECEIVEX10RAW=13 80
2009-06-21 10:14:56.250     TX  &nbs p;  02 62 0F 78 CD 05 19 00
2009-06-21 10:15:01.250     TX  &nbs p;  02 62 0F 78 CD 05 19 00
2009-06-21 10:15:10.921     TX  &nbs p;  02 62 03 4F D2 0F 19 00
2009-06-21 10:15:15.921     TX  &nbs p;  02 62 03 4F D2 0F 19 00
2009-06-21 10:15:20.921     TX  &nbs p;  02 62 03 4F D2 0F 19 00
2009-06-21 10:15:26.187     RX  &nbs p;  SENTINSTEON=0F 44 B1 0F 78 CD 05 19 00 06
2009-06-21 10:15:26.203     RX  &nbs p;  RECEIVEINSTEONRAW=0F 78 CD 0F 44 B1 21 00 FF
Back to Top View Handman's Profile Search for other posts by Handman
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 21 2009 at 13:35 | IP Logged Quote Handman

Wow! Initial testing on one motion sensor evals good with single quotes around the Boolean. I don't see why this should work because if I use the Formula Builder the functions "gray" out in the formula once surrounded by single quotes, and when the function is evaluated, it doesn't return a "0" or a "1" like I would expect - it actually returns the entire function as it is written. You know something about this that I most certainly don't. Off to test the other two motion sensors . . . .
Back to Top View Handman's Profile Search for other posts by Handman
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 21 2009 at 13:59 | IP Logged Quote grif091

I think this may be a glitch in Powerhome which I will post in the bug section. If you look at the Insteon Raw Log the results of those consecutive TX commands actually get posted to the Raw Log but 30 seconds later (when the two Boolean field commands are not surrounded by quotes). When the Boolean field is quoted the results of the first TX query is immediately posted in the Raw Log and acted upon.

The Formula Builder is returning the quoted string as the result. I did not try this but I think if you added a ph_formula('.....') the Boolean commands would have returned the expected results in the Formula Builder.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 21 2009 at 14:16 | IP Logged Quote Handman

Well, it looks like those triggers are firing now. Why would single quotes be required? They always worked before without the quotes and then recently I noticed they stopped. I dunno. I have also been trying to figure out why PH is running so slowly. The program just seems to hang for 30 seconds with nothing in the queue apparently. Take a look at the event log with the triggers for Hallway Lt and Will's Room. Notice the Insteon actions happen +/- 30 seconds later? Dave has some ideas, but nothing we have been able to pin down so far. [OK, no screenshot because I can't get the resolution below 150KB to upload with MS Paint and I am running out of family goodwill - off to Father's Day picnic]




Edited by Handman - June 21 2009 at 14:19
Back to Top View Handman's Profile Search for other posts by Handman
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 21 2009 at 14:18 | IP Logged Quote Handman

Just read your previous post Lee. As I said - everything has been off kilter for weeks now. PH runs slowly and insteon and X10 commands seem to pile up and then flood forth. Can't stay to TS now, but post if you need more info.
Back to Top View Handman's Profile Search for other posts by Handman
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 22 2009 at 00:33 | IP Logged Quote Handman

Bad news Lee. The triggers aren't working properly with single quotes. The triggers are turning off lights when they are on, but they are also turning off lights when they are off - exactly what I was trying to avoid. IOW, the boolean field is just being bypassed from what I can tell. I just never tested the trigger with the lights on earlier. I have a feeling the 30 second delay is caused by something else that has been messing with PH.
Back to Top View Handman's Profile Search for other posts by Handman
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 22 2009 at 12:09 | IP Logged Quote grif091

You are absolutely correct. My mistake. If you just put quotes around the Boolean IF it is no longer functioning as an IF in that setting. If you put the ph_formula('.....') around it to make the IF work again then I am back to the 30 second delay in getting the device responses posted back to PH.

This sure looks like a bug in PH. The query commands are actually working, all six of them in my case, because the 6 results are actually posted back 30 seconds later.

However, I was wondering about the commands the IF is issuing. You query the device status with a command to avoid sending an Off command. Seems like you send two commands when the device is On. Would it not be easier just to send the Off by itself rather than sending a query followed by an Off.   


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 22 2009 at 12:59 | IP Logged Quote Handman

Yes, perhaps you are right. I did it that way because I used to review the event log to evaluate what was working and what wasn't working in PH. Having lights turned off all the time when they weren't on seemed odd to me, and clutters up the event log with a lot of light blue "Insteon Out" entries. If the trigger fires, but the lights were out then I see a "Trigger Check," but no "Insteon Out." If the lights were on, I would see the "Trigger Check" followed by the "Insteon Out" command. This looks cleaner in the event log, but as you point out, doesn't really reduce the network traffic as evidenced by the raw log. OK, I am convinced - maybe it's a bug - and the easiest solution is to just allow commands to be issued that are unnecessary. I will drop the boolean fields for the time being. Maybe that is what is making my system hang so much; who knows?

Edited by Handman - June 23 2009 at 12:00
Back to Top View Handman's Profile Search for other posts by Handman
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 29 2009 at 11:41 | IP Logged Quote dhoward

You definately don't want quotes around the boolean formula since it will then be evaluated as a string and the actual formula within the string will not be executed. The Boolean itself will still be valid and since the string will "evaluate" to other than 0 or false, will be considered true and the trigger action will fire.

The bigger problem is that you've got controller commands within a triggers Boolean formula. This can create a number of problems if the trigger is for an action on the same controller. The Boolean formula is "evaluated" immediately when the trigger is checked. If you've got a PLC/PLM that is responding to X10 and Insteon commands and a particular command sequence fires a trigger, the Boolean formula is evaluated immediately. If that formula contains commands for the PLC/PLM, it will bypass all the normal command queue controls and will cause the PLC/PLM controller to get completely out of sync because it is currently in the middle of processing the commands that caused the trigger to originally fire. I could add code to perform this checking and prevent this situation (it still wouldnt work...you would get an error message) but it would add alot of overhead and just slow PH down.

Now, a couple of ways around it. In your first post, you said you wanted to perform the check to eliminate unnecessary Insteon traffic (don't send an off if already off) but the ph_insteonlevelrt will produce its own Insteon traffic. You could however just use the ph_insteonlevel command as this would return PH's "stored" level (which should be accurate if you've got fairly reliable communications and responder links to the PLC/PLM) and doesnt send out any Insteon commands. Your other option if you want realtime level checking would be to take the ph_insteonlevelrt commands out of the Boolean and put them in the "Action" field like this:

IF (ph_getinsteonlevelrt ("East Light") >0 OR ph_getinsteonlevelrt ("West Light") >0, ph_insteon ("East Light",ioff,0) + ph_insteon ("West Light",ioff,0), 0)

The "Action" of a trigger is queued and sent through the proper command queues so doesnt cause a problem with the controller getting out of sync. It does ultimately result in the trigger action always being "executed" but the actual output would only be performed if your checks are actually true.

Give this a try and I think you'll see a marked improvement. Keep in mind that the ph_insteonlevelrt functions do take a little bit of time (the PLC/PLM has to query the device and wait for a response...this takes a little less than a second so two of them would be a second and a half to 2 seconds...the ph_insteonlevel function would be instantaneous since no comms are issued) so there will be a little bit of delay.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
Handman
Senior Member
Senior Member


Joined: February 02 2009
Location: United States
Online Status: Offline
Posts: 229
Posted: June 29 2009 at 16:08 | IP Logged Quote Handman

Ok, thanks Dave. This all makes sense now. I will switch to the ph_getinsteonlevel function instead. I think with all the motion sensor X10 traffic, this may have been causing problems, but it certainly worked for a while. One reason I was checking the lighting level - in addition to not sending out redundant commands - is because I have some lights turn on to a dim level and then turn off a few minutes later if no motion is detected at night. This was a "safety" feature so things didn't go dark without a warning. Then if a light was turned back on, the macro was terminated. The problem was that lights that were previously off would turn on to a dim setting before turning off. IOW, instead of saving energy by having unused lights turn off, dark rooms were having lights turn on for a period of time! By using the ph_getinsteonlevel command, I prevented the action or macro from executing when the lights had already been turned off.

Anyway, thanks for the explanation and workaround Dave. I'll let you know if my system speeds up. BTW, just bought a new PC and am waiting for the PCI card with dual serial ports so I can hook up PH and see if it runs faster!

Edited by Handman - June 29 2009 at 16:12
Back to Top View Handman's Profile Search for other posts by Handman
 
ann1985
Newbie
Newbie


Joined: October 21 2009
Online Status: Offline
Posts: 1
Posted: October 22 2009 at 03:22 | IP Logged Quote ann1985

grif091 wrote:
I think this may be a glitch in Powerhome which I will post in the bug section. If you look at the Insteon Raw Log the results of those consecutive TX commands actually get posted to the Raw Log but 30 seconds later (when the two Boolean field commands are not surrounded by quotes). When the Boolean field is quoted the results of the first TX query is immediately posted in the Raw Log and acted upon.

The Formula Builder is returning the quoted string as the result. I did not try this but I think if you added a ph_formula('.....') the Boolean commands would have returned the expected results in the Formula Builder.


I AGREE WITH THAT!

__________________
One Tree Hill Season 1-6 DVD Boxset
Back to Top View ann1985's Profile Search for other posts by ann1985
 

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