Skip to content

Commit

Permalink
Add Support for "Fast On" & "Fast Off" on RemoteLinc
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumP committed Jan 7, 2015
1 parent f004bad commit 57dc6b1
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion lib/Insteon/Controller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ must first be put into "awake mode."
=head2 INHERITS
L<Insteon::BaseDevice|Insteon::BaseInsteon/Insteon::BaseDevice>,
L<Insteon::DeviceController|Insteon::BaseInsteon/Insteon::DeviceController>,
L<Insteon::Insteon::MultigroupDevice|Insteon::BaseInsteon/Insteon::Insteon::MultigroupDevice>
=head2 METHODS
Expand All @@ -54,7 +55,7 @@ package Insteon::RemoteLinc;
use strict;
use Insteon::BaseInsteon;

@Insteon::RemoteLinc::ISA = ('Insteon::BaseDevice', 'Insteon::MultigroupDevice');
@Insteon::RemoteLinc::ISA = ('Insteon::BaseDevice','Insteon::DeviceController', 'Insteon::MultigroupDevice');

my %message_types = (
%Insteon::BaseDevice::message_types,
Expand Down Expand Up @@ -84,6 +85,39 @@ sub new
return $self;
}

=item C<derive_link_state([state])>
Overrides routine in BaseObject. Takes the various states available to insteon
devices and returns a derived state of on, off, or 0%-100%.
=cut

sub derive_link_state
{
my ($self, $p_state) = @_;
#Convert Relative State to Absolute State
if ($p_state =~ /^([+-])(\d+)/) {
my $rel_state = $1 . $2;
my $curr_state = '100';
$curr_state = '0' if ($self->state eq 'off');
$curr_state = $1 if $self->state =~ /(\d{1,3})/;
$p_state = $curr_state + $rel_state;
$p_state = 100 if ($p_state > 100);
$p_state = 0 if ($p_state < 0);
}

my $link_state = 'on';
if (grep(/$p_state/i, @{['on_fast', 'off', 'off_fast']})) {
$link_state = $p_state;
}
elsif ($p_state =~ /\d+%?/)
{
$p_state =~ /(\d+)%?/;
$link_state = $1 . '%';
}
return $link_state;
}

=item C<set_awake_time([0-255 seconds])>
Only available for RemoteLinc 2 models.
Expand Down

0 comments on commit 57dc6b1

Please sign in to comment.