From 597ad5ab9613114de03dc8f5f41797a0aba2b929 Mon Sep 17 00:00:00 2001 From: KRKeegan Date: Fri, 12 Apr 2013 17:30:25 -0700 Subject: [PATCH] Insteon: Set Device State on a Received AllLink Broadcast Message Fixes issue #153 The set routine is now called when a broadcase message is received. The flag _pending_cleanup is also set. When a Direct Cleanup Message is received, if the state of the device matches the pending state and the _pending_cleanup flag is set, we assume that this command was already processed. This code is all adjacent to each other, so using a flag should not be confusing. Much of the code was already there, but was commented out by Gregg in his first commit of the new insteon code. This initial commit included a huge number of changes and no notes were added as to why this was disabled in the redux. --- lib/Insteon/BaseInsteon.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Insteon/BaseInsteon.pm b/lib/Insteon/BaseInsteon.pm index 892bb461e..846e56381 100755 --- a/lib/Insteon/BaseInsteon.pm +++ b/lib/Insteon/BaseInsteon.pm @@ -560,12 +560,17 @@ sub _process_message $p_state = $msg{command}; if ($msg{type} eq 'alllink') { + $self->set($p_state, $self); $$self{_pending_cleanup} = 1; } elsif ($msg{type} eq 'cleanup') { - $self->set($p_state, $self); # unless (lc($self->state) eq lc($p_state)) and - # ($msg{type} eq 'cleanup' and $$self{_pending_cleanup}); + if (lc($self->state) eq lc($p_state) and $$self{_pending_cleanup}){ + $self->set($p_state, $self); + } else { + ::print_log("[Insteon::BaseObject] Ignoring Received Direct AllLink Cleanup Message for " + . $self->{object_name} . " since AllLink Broadcast Message was Received.") if $main::Debug{insteon}; + } $$self{_pending_cleanup} = 0; } else { main::print_log("[Insteon::BaseObject] Ignoring unsupported command from "