From: Timothy S. <spa...@ic...> - 2010-09-28 16:00:07
|
Great, thanks. I can commit this later in the evening if someone doesn’t beat me to it. From: Chris Engel [mailto:chr...@gm...] Sent: Tuesday, September 28, 2010 11:46 AM To: The main list for the MisterHouse home automation program Subject: Re: [mh] Coding of Events Question On Mon, Sep 27, 2010 at 7:36 PM, Timothy Spaulding <spa...@ic...<mailto:spa...@ic...>> wrote: Hello All, I could use some advice and another set of eyes to look at what I have and help me understand what I am missing. I’ve defined a Light_item for the laundry room, a Motion_item for the laundry room and Presence_Monitor for the laundry room as well as a light restriction. I only want the light to come on in the laundry room when motion is detected and it is dark. Per my code below, the light comes on in the laundry room (and no motion has been detected) when the $Dark scalar is set and the light is staying on even after motion should have been detected. So your question intrigued me because I wondered if I was seeing the same thing. It is hard to test some of this stuff with kids and a dog running around the house all the time tripping motion sensors. It is hard to know who did what . But I was able to run some tests today and hit the same problem when I disabled a Light_Restriction it automatically turned on the light even though there was a presence object attached and no presence was in the room. Looking into the code I found the problem which appears to be a minor typo. Apply this patch to Light_Item and the issue goes away for me (I have attached as well). Can someone with SVN access apply this ? --- Light_Item.pm.orig 2010-09-28 00:35:39.414087524 -0500 +++ Light_Item.pm 2010-09-28 10:29:59.165138548 -0500 @@ -541,7 +541,7 @@ sub is_on_restriction } if ( defined($p_setby) ) { #Automatic on events are no allowed to shutoff lights if someone is here - if ( $p_setby->isa('Light_Restriction') ) { + if ( $p_setby->isa('Light_Restriction_Item') ) { if ( ! ($self->is_somebody_present($p_setby, $p_state) ) ) { #If someone is in the room, allow the light on! $l_qualified=1; } As a second note, how would I define a Light_Restriction that only allow the Light_item to be turned on between certain hours of the night? I have done this in two different ways, for my dining room light I only allow it on during dinner time, or the hours 17,18,19: my $l_dinner_time = new Light_Restriction_Item(); $l_dinner_time->attach_scalar(\$Hour, 17,18,19); I have also done it with a Save variable which I can adjust with time_now calls since the east side of my house is dark prior to sunset my $l_only_when_backsidedark = new Light_Restriction_Item(); $l_only_when_backsidedark->attach_hash_key(\%Save, 'backsideDark'); # Fix my backside of house dark variable if ($New_Minute && !$Save{backsideDark} && time_now("$Time_Sunset - 1:10")) { print_log "CJE : Setting backsideDark=1"; $Save{backsideDark}=1; set $frontdoor_kpl_G ON; } elsif ($New_Minute && $Save{backsideDark} && time_now($Time_Sunrise)) { print_log "CJE : Setting backsideDark=0"; $Save{backsideDark}=0; set $frontdoor_kpl_G OFF; } As you can see I also set a keypad button this is nice for those times where during storms or other things it gets dark so I can manually override the restriction: if (state_now $frontdoor_kpl_G eq ON && ref $frontdoor_kpl_G->get_set_by && $frontdoor_kpl_G->get_set_by eq $frontdoor_kpl_G) { print_log "CJE : Saw Dark button override"; $Save{backsideDark}=1; } elsif (state_now $frontdoor_kpl_G eq OFF && ref $frontdoor_kpl_G->get_set_by && $frontdoor_kpl_G->get_set_by eq $frontdoor_kpl_G) { print_log "CJE : Saw Dark button override"; $Save{backsideDark}=0; } -- Chris |