Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insteon: Per Device Min/Max Hops Setting #164

Merged
merged 5 commits into from
Jul 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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