Skip to content

Commit

Permalink
Add call to link_data3 in Insteon_PLM::has_link
Browse files Browse the repository at this point in the history
  • Loading branch information
mstovenour committed Dec 17, 2013
1 parent 8f43939 commit c271c0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions lib/Insteon/AllLinkDatabase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ sub delete_orphan_links
#Ask self what we should have in data3
#For rspndr, D3 = rspndr group; For ctrlr, D3 = ctrlr group
my $link_data3 = $$self{device}->link_data3(($is_controller ? $group : $member->group), $is_controller);
::print_log("[Insteon::AllLinkDatabase] DEBUG-omg: member: ".$member->get_object_name."(".$member->device_id.") data3: $data3; link data3: $link_data3") if $main::Debug{insteon} >= 5;
::print_log("[Insteon::AllLinkDatabase] DEBUG-omg: member: ".$member->get_object_name."(".$member->device_id.") data3: $data3; link data3: $link_data3") if $main::Debug{insteon} >= 5;
if ($data3 eq $link_data3){
$link_defined = 1;
$recip_data3 = ($is_controller) ? $member->group : $group;
Expand Down Expand Up @@ -612,6 +612,7 @@ sub delete_orphan_links

# Does a reciprocal link exist?
if (! $linked_device->has_link($$self{device},$group,($is_controller) ? 0 : 1, lc $recip_data3)) {
::print_log("[Insteon::AllLinkDatabase] DEBUG-omg: No reciprocal link: \$recip_data3 = $recip_data3") if $main::Debug{insteon} >= 5;
$delete_req{cause} = "no reciprocal link was found on " . $linked_device->get_object_name;
push @{$$self{delete_queue}}, \%delete_req;
}
Expand Down Expand Up @@ -2778,7 +2779,17 @@ sub has_link
my ($self, $insteon_object, $group, $is_controller, $data3) = @_;
my $key = $self->get_linkkey($insteon_object->device_id,
$group, $is_controller, $data3);
return (defined $$self{aldb}{$key});

#Now that we have a linkkey, compare the linkkey's data3 value.
my $found = 0;
if (defined $$self{aldb}{$key}) {
#Ask self what we should have in data3
$data3 = $$self{device}->link_data3($data3,$is_controller);

$found++ if( $$self{aldb}{$key}{data3} == $data3);
}

return ($found);
}

=back
Expand Down
4 changes: 2 additions & 2 deletions lib/Insteon/Lighting.pm
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,15 @@ sub link_data3
{
my ($self, $group, $is_controller) = @_;

my $link_data3 = SUPER::link_data3($group, $is_controller);
my $link_data3 = $self->SUPER::link_data3($group, $is_controller);

if( !$is_controller) { #is_responder
#For I2CS devices the default data3 for responder links is 01.
#This is to support the I2CS In-LineLinc Relay. There may be more
#permutations of the 00 vs. 01 problem and I1 devices may have
#the same requirement. This code is a work in progress as more
#information is gathered about Relay type devices.
if ($$self{device}->can('engine_version') && $$self{device}->engine_version eq 'I2CS') {
if ($self->can('engine_version') && $self->engine_version eq 'I2CS') {
$link_data3 = '01';
::print_log("[Insteon::SwitchLincRelay] Overriding link_data3 to 01 for group 01");
}
Expand Down

0 comments on commit c271c0a

Please sign in to comment.