From: Tim S. <tp...@ma...> - 2007-02-27 20:55:11
|
On Tue, February 27, 2007 13:40, ebroo said: > Hi all, > > I'm trying to evaluate a state before setting an action in motion, but the > state never > seems to change correctly. > Using the below code, I hope to if motion sensor is active check the > timer_garage to > see if it's expired, if not set it to 60 second, then alert. If the timer > is not > expired, do nothing. > > When motion is seen, the timer is always zero, so there is always action - > Any > thoughts? > > $timer_garage = new Timer(); > > my @phrase = ("Somthing is stirring in the garage", "Cat wants in", > "Doofus wants > in", "guess who wants in"); > if (state_now $motion1 eq 'motion' and > inactive $timer_garage) { > set $timer_garage 60; > speak ("The cat wants in"); > speak ( rooms=> "clyde", volume => "80", engine => "MS", voice => > "Microsoft Mary", > mode => "unmuted", text=> "The Cat is waiting to be let in." ); > > net_im_send(to => "IM1", text => "$phrase[rand @phrase] $Time_Date > "); > net_im_send(to => "IM2", text => "$phrase[rand @phrase] $Time_Date > "); > > } Here's a bit of code I use. See if this helps: # noloop=start my $br2_timer = new Timer; # noloop=stop # #each pass, if still motion, reset the timer to the max. More timer if #everone's awake if (state_now $sensor_corrine eq 'motion') { logit ("/var/log/mh/occupancy.log"," Corrines bedroom occupied.") if (inactive $br2_timer); if (state $mode_sleeping eq "nobody") { set $br2_timer 600; logit ("/var/log/mh/occupancy.log"," Added 600 seconds to br2."); if ($Dark) { set $corrines_bedroom_light ON; } } else { set $br2_timer 200; logit ("/var/log/mh/occupancy.log"," Added 200 seconds to br2."); } } if (expired $br2_timer) { logit ("/var/log/mh/occupancy.log","Corrines bedroom unoccupied."); } -- Tim Sailer Coastal Internet, Inc. www.buoy.com 631-399-2910 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |