CheckTrigger in Events module

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

CheckTrigger in Events module

Postby hhg » Sat Sep 18, 2010 3:00 pm

Hi

I had some troubles getting my Oregon sensor to control the bathroom fan when I noticed this in the debug log:
2010/09/18 11:27:06 [Events] Check trigger 67 > 63 = False
2010/09/18 11:27:06 [Events] Check trigger 67 < 63 = False

Well, turns out to be line 343 that failed:

Code: Select all
IF IsDigit(sValue) AND IF IsDigit(sCond) = FALSE THEN

So I replaced that block with the one from CheckCondition:

Code: Select all
CASE ">"
         sValue = "" & sValue ' be sure it are strings
         sCond = "" & sCond
         IF IsDigit(sValue) AND IsDigit(sCond) THEN
           IF Val(sValue) > Val(sCond) THEN bReturn = TRUE
         ENDIF

Do the same for > an it works - And then I realised that CheckTrigger and CheckCondition does the same, and are identical except for the log messages, so in the end, I just replaced the call in line line 218 in CheckDeviceChangeEvent with a call of CheckCondition:

Code: Select all
IF NOT CheckCondition(sValue, rResult["triggers.param3"], rResult["triggers.param4"]) THEN CONTINUE

And then deleting the CheckTrigger procedure

/hhg
hhg
Starting Member
Starting Member
 
Posts: 20
Joined: July 2010
Location: Denmark

Re: CheckTrigger in Events module

Postby RDNZL » Sat Sep 18, 2010 3:51 pm

Thanks, I have added your changes and deleted the CheckTrigger() code.
Regards, Ron.
User avatar
RDNZL
Forum Moderator
Forum Moderator
 
Posts: 996
Joined: September 2006
Location: Dordrecht, The Netherlands

Re: CheckTrigger in Events module

Postby RDNZL » Thu Sep 23, 2010 4:37 pm

I have added numerous fixes to events code and editors again in revision 420.

I now finally know why older code failed to work, DoEvent() and RunActions() got a result set as argument, that set included all records of the same type of trigger but without additional checks for value and field, so they also run all triggers and actions that where not meeting the conditions. 8)

And although it looked very clean it was not efficient, since some sql queries where done over and over again in different routines.
Now I just pass the needed value(s) directly so extra queries are not needed anymore.
Regards, Ron.
User avatar
RDNZL
Forum Moderator
Forum Moderator
 
Posts: 996
Joined: September 2006
Location: Dordrecht, The Netherlands


Return to DomotiGa Forum

Who is online

Users browsing this forum: No registered users and 1 guest