Patch with various Insteon and LOMP fixes/improvements for review/integration

View: New views
2 Messages — Rating Filter:   Alert me  

Patch with various Insteon and LOMP fixes/improvements for review/integration

by Brad Bosch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings,

I have been pursuing a rather ambitious goal to automate all my lights
(18 Insteon devices of various types) via the LOMP objects and several
sensors (17 X10 motion detectors and 5 door switches). I wanted to
combine full automation with convient manual overrides.  In the
process, I have discovered a few bugs and weak areas in various
objects and I have completed/extended the Light_Switch_Item object
which seemed to be unfinished.  In addition to establishing presence,
the new Light_Switch_Item in conjunction with enhancements to
Light_Item provides a convenient switch activated manual override mode
which expires based on time and occupancy (rather than just time).  In
other words, if I operate a switch manually, I want the ability to
lock the switch on or off until the room has been considered vacant
for a specified amount of time.

I'll try to split up the patches into logical chunks and I'll start
here with a few small improvements/fixes, some of which are required
to use my new Light_Switch_Item code.

If no problems are seen with these changes, will someone please
incorporate them into the Subversion code base?

Change Log:

lib/Insteon_Device.pm:
Allow repeated events from Insteon controllers (dimmers, KPLs, remote
links, etc).  This is very useful because it allows a single
switch/button to perform additional functions such as establishing or
clearing manual mode thru repeated on or off events.

lib/Light_Restriction_Item.pm:
Fix a bug where an MH reload didn't properly query the state of
attached objects after object states are restored.

lib/Insteon_Link.pm:
This fix was discussed on the list earlier but has not made it into
subversion yet.  It is required to prevent infinite loops when dimming
devices cross-linked to KPLs or dimmers.

lib/Motion_Item.pm:
Ignore "normal" states from X10 security motion detectors.  These
events seem to be sent almost immediately after the "alert" event for
these devices and was causing the 'still' state to be set too soon.
It's better to rely on the timeout for returning to the 'still' state.

bin/mh:
Prevent a crash I encountered at one point.  I don't remember at the
moment how it was triggered, but the extra check seems like a good
idea anyway.

Comments?

Thanks,

--Brad

Index: lib/Insteon_Device.pm
===================================================================
--- lib/Insteon_Device.pm (revision 1657)
+++ lib/Insteon_Device.pm (working copy)
@@ -405,7 +405,7 @@
  or (&main::set_by_to_target($p_setby) eq $self->interface)))))
  {
  # don't reset the object w/ the same state if set from the interface
- return if (lc $p_state eq lc $self->state) and $self->is_acknowledged;
+ return if (lc $p_state eq lc $self->state) and $self->is_acknowledged and not (($p_setby->isa('Insteon_Device') and (($p_setby eq $self))));
  &::print_log("[Insteon_Device] " . $self->get_object_name()
  . "::set($p_state, $p_setby)") if $main::Debug{insteon};
  $self->SUPER::set($p_state,$p_setby,$p_response) if defined $p_state;
Index: lib/Light_Restriction_Item.pm
===================================================================
--- lib/Light_Restriction_Item.pm (revision 1657)
+++ lib/Light_Restriction_Item.pm (working copy)
@@ -110,7 +110,7 @@
 }
 
 sub _check_values {
-   if ($main::Startup) {
+   if ($main::Startup or $main::Reload) {
       foreach (@CheckStartup) {
          if ($$_{'attached_object'}) {
             &::print_log("$$_{object_name}: Checking attached object after startup") if $main::Debug{occupancy};
Index: lib/Insteon_Link.pm
===================================================================
--- lib/Insteon_Link.pm (revision 1657)
+++ lib/Insteon_Link.pm (working copy)
@@ -415,15 +419,24 @@
 
 sub request_status
 {
- my ($self,$requestor) = @_;
- if ($self->group ne '01') {
- &::print_log("[Insteon_Link] requesting status for members of " . $$self{object_name});
- foreach my $member (keys %{$$self{members}}) {
- $$self{members}{$member}{object}->request_status($self);
- }
- } else {
- $self->SUPER::request_status($requestor);
- }
-}
+    my ($self,$requestor) = @_;
+    #if ($$self{members}) {
+    if ($self->group ne '01'
+       and (!(ref $requestor) or ($requestor eq $self))) {
+       &::print_log("[Insteon_Link] requesting status for members of "
+           . $$self{object_name});
+       foreach my $member (keys %{$$self{members}}) {
+           my $member_obj = $$self{members}{$member}{object};
+           &::print_log("[Insteon_Link_Debug] working on "
+               . $member_obj->get_object_name
+               . " for requestor "
+               . $requestor->get_object_name);
+           $member_obj->request_status($self);
+       }
+    } else {
+       #if ($self->is_root && $self->is_responder) {
+       $self->SUPER::request_status($requestor);
+    }
+}
 
 1;
Index: lib/Motion_Item.pm
===================================================================
--- lib/Motion_Item.pm (revision 1657)
+++ lib/Motion_Item.pm (working copy)
@@ -87,8 +87,8 @@
 {
  my ($self,$p_state,$p_setby) = @_;
 
-   # Ignore the dark/light states
-   if (($p_state eq 'dark') or ($p_state eq 'light')) {
+   # Ignore the dark/light and normal states
+   if (($p_state eq 'dark') or ($p_state eq 'light') or ($p_state =~ /^normal/i)) {
       return;
    }
 
@@ -101,7 +101,7 @@
    # Hawkeye (MS13) motion detector and security sensors
    if (($p_state eq 'on') or ($p_state =~ /^alert/i)) {
       $p_state = 'motion';
-   } elsif (($p_state eq 'off') or ($p_state =~ /^normal/i)) {
+   } elsif (($p_state eq 'off')) {
       $p_state = 'still';
    }
 
Index: bin/mh
===================================================================
--- bin/mh (revision 1657)
+++ bin/mh (working copy)
@@ -2424,7 +2424,7 @@
                     &print_log($log_msg) unless $log_msg eq '1';
 #                   $state2 = $state1 unless defined $state2;
                     $state2 = $state1 if $state2 eq 'all_states';
-                    if ($object2->can('set')) {
+                    if (ref $object2 && $object2->can('set')) {
                                 # Make sure we don't get into a loop with cross-tied objects
                         unless ($object1->{set_by} and
                                 ($object1->{set_by} eq $object2 or

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


Re: Patch with various Insteon and LOMP fixes/improvements for review/integration

by Gregg Liming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brad Bosch wrote:

> If no problems are seen with these changes, will someone please
> incorporate them into the Subversion code base?

For the exception of the two Insteon-related items, I've been running w/
your code mods since submitted w/o problems.  Wrt the Insteon-related
items, I'm assuming they're ok (one was my prior suggestions to Marc and
  the other seems ok via inspection) as I'm currently using an entirely
different code base.  All submissions committed.

Gregg

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