I found the problem, but I need some feedback before I can commit a fix.  I found these lines in the setup subroutine, which gets run before the items are defined:
 

# This was taken from lib/trigger_code.pl so that libraries involved with serial ports

# and sockets could create new triggers. See lib/Weather_daviswm2.pm for an example of

# why this is a good idea.

&triggers_read;

 

I don't understand what "so that libraries involved with serial ports and sockets could create new triggers" means.  I looked at the Davis and didn't see why it would need to have its trigger defined so early in the startup process.  I'm inclined to remove these lines, since triggers_read is already run after the items are defined.  Is anyone using a Davis WM2, and can help me test?  

 

David

 

----- Original Message -----
From: Michael Stovenour
To: misterhouse-users@lists.sourceforge.net
Sent: Tuesday, December 22, 2009 5:43 PM
Subject: [mh] Problems with changes to trigger_code.pl and item referencesin triggers

I just recently upgraded from v2-105 to the latest svn revision on my main system.  Iím now having trouble with some of my triggers and I believe it is due to code that David Norwood introduced in lib/trigger_code.pl.  For now I commented out the eval() and related if {} block and all seems to be working.  While I understand the reason for the eval() I must wonder if that code has the right context for evaluating code that will otherwise run in the polling loop.

The error I received is:

Loading other modules

Starting setup

 - using simple Text distance function

 - reading previous log files

 - archiving previous /var/local/misterhouse/data/logs/*.log files .....

12/21/09 09:15:24 PM Error: trigger 'yard_east_motion' has an error, disabling

12/21/09 09:15:24 PM   Code = state_now $yard_east_motion eq 'motion'

12/21/09 09:15:24 PM   Result = Global symbol "$yard_east_motion" requires explicit package name at (eval 367) line 1.

 

The definition for the yard_east_motion trigger from data/triggers.current is:

name=yard_east_motion type=Disabled triggered=1233369028

state_now $yard_east_motion eq 'motion'

speak 'Rabit east side of the house';

 

The item definition for the yard_east_motion item is defined in code/items.mht as:

X10MS,              G13,                yard_east_motion,   Sensors|Yard,       Motion

 

After doing some print_log() tests, Iíve come to the conclusion that the item objects do not exist when lib/trigger_code.pl tries to eval() the triggers.  Is there another way to define the triggers so they reference item objects in such a way to keep lib/trigger_code.pl happy?

 

Michael

 


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev


________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365