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: Add Is Deaf Routine for Battery Devices #282

Merged
merged 6 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 3 additions & 4 deletions lib/Insteon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,8 @@ sub scan_all_linktables
{
my $candidate_object = $_;
if ($candidate_object->is_root and
!($candidate_object->isa('Insteon::RemoteLinc')
or $candidate_object->isa('Insteon::InterfaceController')
or $candidate_object->isa('Insteon::MotionSensor')))
!($candidate_object->is_deaf
or $candidate_object->isa('Insteon::InterfaceController')))
{
push @_scan_devices, $candidate_object;
&main::print_log("[Scan all linktables] INFO1: "
Expand Down Expand Up @@ -511,7 +510,7 @@ sub sync_all_links
# iterate over all registered objects and compare whether the link tables match defined scene linkages in known Insteon_Links
for my $obj (&Insteon::find_members('Insteon::BaseController'))
{
if ($obj->isa('Insteon::RemoteLinc') or $obj->isa('Insteon::MotionSensor'))
if ($obj->is_deaf)
{
&main::print_log("[Sync all links] Ignoring links from 'deaf' device: " . $obj->get_object_name);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Insteon/AllLinkDatabase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ sub delete_orphan_links
# first, make sure that the health of ALDB is ok
if ($self->health ne 'good')
{
if ($$self{device}->isa('Insteon::RemoteLinc') or $$self{device}->isa('Insteon::MotionSensor'))
if ($self->is_deaf)
{
&::print_log("[Insteon::AllLinkDatabase] Delete orphan links: ignoring link from deaf device: $selfname");

Expand Down Expand Up @@ -588,7 +588,7 @@ sub delete_orphan_links
}
else # is a non-PLM device
{
if ($linked_device->isa('Insteon::RemoteLinc') or $linked_device->isa('Insteon::MotionSensor'))
if ($linked_device->is_deaf)
{
&::print_log("[Insteon::AllLinkDatabase] Delete orphan links: ignoring link from $selfname to 'deaf' device: " . $linked_device->get_object_name);
}
Expand Down Expand Up @@ -754,7 +754,7 @@ sub delete_orphan_links
{
$member = $member->get_root;
}
if ($member->isa('Insteon::RemoteLinc') or $member->isa('Insteon::MotionSensor'))
if ($member->is_deaf)
{
&::print_log("[Insteon::AllLinkDatabase] ignoring link from " . $link->get_object_name . " to " .
$member->get_object_name);
Expand Down Expand Up @@ -2830,7 +2830,7 @@ sub delete_orphan_links
}
if ($member->isa('Insteon::BaseDevice'))
{
if ($member->isa('Insteon::RemoteLinc') or $member->isa('Insteon::MotionSensor'))
if ($member->is_deaf)
{
&::print_log("[Insteon::ALDB_PLM] ignoring link from PLM to " .
$member->get_object_name);
Expand Down
18 changes: 18 additions & 0 deletions lib/Insteon/BaseInsteon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ sub new
$$self{hops_left_count} = 0;
$$self{max_hops_count} = 0;
$$self{outgoing_hop_count} = 0;
$$self{is_deaf} = 0;

return $self;
}
Expand Down Expand Up @@ -1308,6 +1309,23 @@ sub set_receive
$self->SUPER::set_receive($p_state, $p_setby, $p_response);
}

=item C<is_deaf()>

Returns true if the device must be awake in order to respond to messages. Most
devices are not deaf, currently devices that are deaf are battery operated
devices such as the Motion Sensor, RemoteLinc and TriggerLinc.

At the BaseObject level all devices are defined as deaf. Objects which inherit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean that the devices are defined as NOT deaf, since line 1263 sets it to 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, sure did. More evidence of why I shouldn't write things late at night.

BaseObject should redefine is_deaf as necessary.

=cut

sub is_deaf
{
my ($self) = @_;
return $$self{is_deaf};
}

=item C<is_controller()>

Returns true if the device is a controller.
Expand Down
1 change: 1 addition & 0 deletions lib/Insteon/Controller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ sub new
$$self{queue_timer} = new Timer;
}
bless $self,$class;
$$self{is_deaf} = 1;
return $self;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Insteon/Security.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ sub new
$$self{queue_timer} = new Timer;
}
bless $self,$class;
$$self{is_deaf} = 1;
return $self;
}

Expand Down Expand Up @@ -775,6 +776,7 @@ sub new
my $self = new Insteon::BaseDevice($p_deviceid,$p_interface);
$$self{message_types} = \%message_types;
bless $self,$class;
$$self{is_deaf} = 1;
return $self;
}

Expand Down