Skip to content

Commit

Permalink
Merge pull request #471 from hplato/iolinc_door
Browse files Browse the repository at this point in the history
Iolinc door
  • Loading branch information
hollie committed Mar 2, 2015
2 parents dd7e709 + 71b0649 commit 23205d5
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions lib/Insteon/IOLinc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ defined as the controller.
Instructions for this object are contained in C<Insteon::IOLinc_sensor>.
=head3 DOOR CHILD OBJECT
IOLinc devices are often used to monitor/control doors such as garage doors (Smarthome
has a full kit for this). The Insteon::IOLinc_door simplifies this use case by creating
an object that has open/closed states, as well as sets the device to the proper
Momentary_B mode.
However, if you want to directly link an obect to the sensor
be sure to use the normal SCENE_MEMBER code in your mht file with the IOLinc
defined as the controller.
Instructions for this object are contained in C<Insteon::IOLinc_door>.
=head2 NOTES
This module works with the Insteon IOLinc device from Smarthome. The EZIO device
Expand Down Expand Up @@ -173,6 +187,9 @@ sub set
if (ref $$self{child_sensor}){
$$self{child_sensor}->set_receive($p_state, $p_setby, $p_respond);
}
if (ref $$self{child_door}){
$$self{child_door}->set_receive($p_state, $p_setby, $p_respond);
}
}
}
else {
Expand Down Expand Up @@ -223,6 +240,10 @@ sub _is_info_request
if (ref $$self{child_sensor}){
$$self{child_sensor}->set_receive($child_state, $ack_setby);
}
$ack_setby = $$self{child_door} if ref $$self{child_door};
if (ref $$self{child_door}){
$$self{child_door}->set_receive($child_state, $ack_setby);
}
delete($$parent{child_status_request_pending});
}
elsif ($cmd eq 'get_operating_flags') {
Expand Down Expand Up @@ -633,4 +654,90 @@ You should have received a copy of the GNU General Public License along with thi
=cut

=head1 B<Insteon::IOLinc_door>
=head2 SYNOPSIS
User Code:
$io_device_door = new Insteon::IOLinc_door($io_device);
Where $io_device is the parent device defined above.
=head2 DESCRIPTION
Creates a door_item like device when the IOLinc is used to track/control a door, such
as the garage door kit. Provides and open and closed state, and a set will trigger a
relay close. Adding this object will place the parent device into Momentary B mode.
Tie_events can be used on this child object. However, if you want to directly
link an obect to the sensor be sure to use the normal SCENE_MEMBER code in your
mht file with the main IOLinc device defined as the controller.
=head2 INHERITS
L<Generic_Item|Generic_Item>
=head2 METHODS
=over
=cut

package Insteon::IOLinc_door;
use strict;

@Insteon::IOLinc_door::ISA = ('Generic_Item');

=item C<new()>
Instantiates a new object.
=cut

sub new {
my ($class, $parent) = @_;
my $self = new Generic_Item();
bless $self, $class;
$$self{parent} = $parent;
$$self{parent}{child_door} = $self;
@{$$self{states}} = ('open','closed','error');
$parent->set_relay_mode("Momentary_B");
return $self;
}

=item C<set_receive()>
Receives sensor state messages from the parent object and sets the state of this
device accordingly.
=cut

sub set_receive {
my ($self, $p_state, $p_setby, $p_respond) = @_;
my $n_state;
if ($p_state eq "on") {
$n_state = "open";
} elsif ($p_state eq "off") {
$n_state = "closed";
} else {
$n_state = "error";
}
$self->SUPER::set($n_state, $p_setby, $p_respond);
}

=item C<set_receive()>
Triggers the relay if the set request state differs from the current state.
=cut

sub set {
my ($self, $p_state, $p_setby, $p_respond) = @_;
main::print_log("[Insteon::IOlinc_door] set method called. current state: " . $self->state . " set to state: " . $p_state) if $self->debuglevel(1, 'insteon');

$$self{parent}->set("on") if ($p_state ne $self->state);
}


1;

0 comments on commit 23205d5

Please sign in to comment.