diff --git a/lib/Insteon/BaseInsteon.pm b/lib/Insteon/BaseInsteon.pm index 4aaad4330..4b998e4f7 100644 --- a/lib/Insteon/BaseInsteon.pm +++ b/lib/Insteon/BaseInsteon.pm @@ -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"; @@ -196,6 +198,36 @@ sub group return $$self{m_group}; } +=item C + +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 + +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 Used to track the number of hops needed to reach a device. Will store the past @@ -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}; } diff --git a/lib/Insteon/Message.pm b/lib/Insteon/Message.pm index a9c8966b2..c83535f7a 100644 --- a/lib/Insteon/Message.pm +++ b/lib/Insteon/Message.pm @@ -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) {