From: Andy <myi...@st...> - 2008-05-14 23:26:50
|
Hi, I think the problem is in the statement below. The time_greater_than() function cannot handle clock based mathematics. if (time_greater_than "$Time_Sunset - 0:15" or time_less_than "$Time_Sunrise - 0:15") So try using the time_add() function to first do the mathematics. if (time_greater_than(time_add "$Time_Sunset - 0:15") or time_less_than(time_add "$Time_Sunrise - 0:15")) Let us know how you get on. Andy. mo...@be... wrote: > 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--- > > |