CheckTrigger in Events module

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

Post Reply
hhg
Starting Member
Starting Member
Posts: 20
Joined: Sun Jul 18, 2010 6:45 pm
Location: Denmark

CheckTrigger in Events module

Post by hhg »

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
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: CheckTrigger in Events module

Post by RDNZL »

Thanks, I have added your changes and deleted the CheckTrigger() code.
Regards, Ron.
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: CheckTrigger in Events module

Post by RDNZL »

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.
Post Reply

Return to “DomotiGa Forum”