Skip to content

Commit

Permalink
Merge pull request #164 from krkeegan/insteon_min_max_hops
Browse files Browse the repository at this point in the history
Insteon: Per Device Min/Max Hops Setting
  • Loading branch information
krkeegan committed Jul 30, 2013
2 parents 6069ecd + 4835bd9 commit 88c83b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions lib/Insteon/BaseInsteon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ sub new
$self->restore_data('default_hop_count', 'engine_version');

$self->initialize();
$$self{max_hops} = 3;
$$self{min_hops} = 0;
$$self{level} = undef;
$$self{flag} = "0F";
$$self{ackMode} = "1";
Expand Down Expand Up @@ -196,6 +198,36 @@ sub group
return $$self{m_group};
}

=item C<max_hops($int)>
Sets the maximum number of hops that may be used in a message sent to the device.
The default and maximum number is 3. $int is an integer between 0-3.
This value is NOT saved on reboot, as such likely should be called in a $Reload loop.
=cut

sub max_hops {
my ($self, $hops) = @_;
$$self{max_hops} = $hops if $hops;
return $$self{max_hops};
}

=item C<min_hops($int)>
Sets the minimum number of hops that may be used in a message sent to the device.
The default and minimum number is 0. $int is an integer between 0-3.
This value is NOT saved on reboot, as such likely should be called in a $Reload loop.
=cut

sub min_hops {
my ($self, $hops) = @_;
$$self{min_hops} = $hops if $hops;
return $$self{min_hops};
}

=item C<default_hop_count([hops])>
Used to track the number of hops needed to reach a device. Will store the past
Expand Down Expand Up @@ -225,6 +257,10 @@ sub default_hop_count
$high = $_ if ($high < $_);;
}
$$self{default_hop_count} = $high;
$$self{default_hop_count} = $$self{max_hops} if ($$self{max_hops} &&
$$self{default_hop_count} > $$self{max_hops});
$$self{default_hop_count} = $$self{min_hops} if ($$self{min_hops} &&
$$self{default_hop_count} < $$self{min_hops});
return $$self{default_hop_count};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Insteon/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ sub _derive_interface_data
}
else
{
my $hop_count = $self->send_attempts + $self->setby->default_hop_count - 1;
my $hop_count = $self->setby->default_hop_count;
$cmd.=$self->setby->device_id();
if ($self->command_type =~ /insteon_ext_send/i)
{
Expand Down

0 comments on commit 88c83b2

Please sign in to comment.