From: <mo...@be...> - 2008-05-14 20:44:31
|
I've been working on addind a motion sensor to my house. Nothing fancy compared to what a lot of others are doing.. I can't figure out what's wrong with my code. What I want to do is only have the garage light turned on when it's dark enough in my garage to actually need the light. That's roughly between sunrise and sunset. It works if I don't try do the time comparison, so there must be something I don't have coded right. Anyone have any suggestions? ---BEGIN INCLUDE--- # 03/29/08 # Code to detect motion from the MR14A on the kitchen door. This code # was # copied from the example code on the Wiki # http://misterhouse.wikispaces.com/MotionDetection # my $Door_Motion_timer = new Timer; my $Door_Motion_state; if ($state = state_now $Door_Motion) { set $Door_Motion_timer 120; if ($Door_Motion_state ne $state) { if ($state eq 'on') { speak "Someone just opened the Kitchen Door."; if (time_greater_than "$Time_Sunset - 0:15" or time_less_than "$Time_Sunrise - 0:15"){ set $Garage_Light 'on'; } else { speak "The Kitchen door is closed."; set $Garage_Light 'off'; set $Door_Motion_timer 0; } $Door_Motion_state = $state; } } } --- END INCLUDE--- -- -Monte |