diff --git a/lib/Generic_Item.pm b/lib/Generic_Item.pm index acf58f291..0399bf523 100644 --- a/lib/Generic_Item.pm +++ b/lib/Generic_Item.pm @@ -1340,6 +1340,24 @@ sub user_data { return \%{$$self{user_data}}; } +=item C + +Returns 1 if debug_group or this device is at least debug level 'level', otherwise returns 0. + +=cut + +sub debuglevel +{ + my ($object, $debug_level, $debug_group) = @_; + $debug_level = 1 unless $debug_level; + my $objname; + $objname = lc $object->get_object_name if defined $object; + ::print_log("[Generic_Item] debuglevel: Processing debug for object $objname ... " . $main::Debug{$objname}) if $main::Debug{$debug_group} >= 5; + return 1 if $main::Debug{$debug_group} >= $debug_level; + return 1 if defined $objname && $main::Debug{$objname} >= $debug_level; + return 0; +} + =back =head2 PACKAGE FUNCTIONS diff --git a/lib/Insteon.pm b/lib/Insteon.pm index a2000bd70..9665ef1f6 100755 --- a/lib/Insteon.pm +++ b/lib/Insteon.pm @@ -406,7 +406,7 @@ sub scan_all_linktables push @_scan_devices, $candidate_object; &main::print_log("[Scan all linktables] INFO1: " . $candidate_object->get_object_name - . " will be scanned.") if $candidate_object->debuglevel(1); + . " will be scanned.") if $candidate_object->debuglevel(1, 'insteon'); } else { @@ -906,28 +906,6 @@ sub init { } -=item C - -Returns 1 if Insteon or this device is at least debug level 'level', otherwise returns 0. - -=cut - -sub debuglevel -{ - my ($object, $debug_level) = @_; - $debug_level = 1 unless $debug_level; - my $objname; - #try { - $objname = lc $object->get_object_name if defined $object; - #} catch { - # &::print_log("$object doesn't have a get_object_name function.") if $main::Debug{insteon} >= 2; - #} - &::print_log("Insteon::debuglevel: Processing debug for object $objname ... " . $main::Debug{$objname}) if $main::Debug{insteon} >= 5; - return 1 if $main::Debug{insteon} >= $debug_level; - return 1 if defined $objname && $main::Debug{$objname} >= $debug_level; - return 0; -} - =item C Generates and sets the voice commands for all Insteon devices. @@ -1083,7 +1061,7 @@ Walks through every Insteon device and checks the aldb object version for I1 vs. sub check_all_aldb_versions { - main::print_log("[Insteon] DEBUG4 Checking aldb version of all devices") if Insteon::debuglevel(undef,4); + main::print_log("[Insteon] DEBUG4 Checking aldb version of all devices") if ($main::Debug{insteon} >= 4); my @ALDB_devices = (); push @ALDB_devices, Insteon::find_members("Insteon::BaseDevice"); @@ -1097,21 +1075,21 @@ sub check_all_aldb_versions { main::print_log("[Insteon] DEBUG4 Checking aldb version for " . $ALDB_device->get_object_name() - . " ($count of $ALDB_cnt)") if ($ALDB_device->debuglevel(4)); + . " ($count of $ALDB_cnt)") if ($ALDB_device->debuglevel(4, 'insteon')); $ALDB_device->check_aldb_version(); } else { main::print_log("[Insteon] DEBUG4 " . $ALDB_device->get_object_name . " does not have its own aldb ($count of $ALDB_cnt)") - if ($ALDB_device->debuglevel(4)); + if ($ALDB_device->debuglevel(4, 'insteon')); } } - main::print_log("[Insteon] DEBUG4 Checking aldb version of all devices completed") if Insteon::debuglevel(undef,4); + main::print_log("[Insteon] DEBUG4 Checking aldb version of all devices completed") if ($main::Debug{insteon} >= 4); } sub check_thermo_versions { - main::print_log("[Insteon] DEBUG4 Initializing thermostat versions") if Insteon::debuglevel(undef,4); + main::print_log("[Insteon] DEBUG4 Initializing thermostat versions") if ($main::Debug{insteon} >= 4); my @thermo_devices = (); push @thermo_devices, Insteon::find_members("Insteon::Thermostat"); @@ -1121,18 +1099,17 @@ sub check_thermo_versions $thermo_device->get_root()->engine_version eq "I2CS"){ main::print_log("[Insteon] DEBUG4 Setting thermostat " . $thermo_device->get_object_name() . " to i2CS") - if ($thermo_device->debuglevel(4)); + if ($thermo_device->debuglevel(4, 'insteon')); bless $thermo_device, 'Insteon::Thermo_i2CS'; $thermo_device->init(); } else { main::print_log("[Insteon] DEBUG4 Setting thermostat " . $thermo_device->get_object_name() . " to i1") - if ($thermo_device->debuglevel(4)); + if ($thermo_device->debuglevel(4, 'insteon')); bless $thermo_device, 'Insteon::Thermo_i1'; } } - #main::print_log("[Insteon] DEBUG4 Checking thermostat version of all devices completed") if ($self->debuglevel(4)); } =back @@ -1208,7 +1185,7 @@ sub _active_interface my ($self, $interface) = @_; # setup hooks the first time that an interface is made active if (!($$self{active_interface}) and $interface) { - &main::print_log("[Insteon] Setting up initialization hooks") if $self->debuglevel(); + &main::print_log("[Insteon] Setting up initialization hooks") if $main::Debug{insteon}; &main::MainLoop_pre_add_hook(\&Insteon::BaseInterface::check_for_data, 1); &main::Reload_post_add_hook(\&Insteon::check_all_aldb_versions, 1); &main::Reload_post_add_hook(\&Insteon::BaseInterface::poll_all, 1); @@ -1221,18 +1198,6 @@ sub _active_interface return $$self{active_interface}; } -=item C - -Returns 1 if Insteon or this device is at least debug level 'level', otherwise returns 0. - -=cut - -sub debuglevel -{ - my ($self, $debug_level) = @_; - return Insteon::debuglevel(undef, $debug_level); -} - =item C Adds a list of objects to be tracked. diff --git a/lib/Insteon/AllLinkDatabase.pm b/lib/Insteon/AllLinkDatabase.pm index 9ab9d79f8..594186190 100644 --- a/lib/Insteon/AllLinkDatabase.pm +++ b/lib/Insteon/AllLinkDatabase.pm @@ -145,7 +145,7 @@ sub query_aldb_delta $self->{_aldb_changed_callback} = undef; eval ($callback); &::print_log("[Insteon::AllLinkDatabase] " . $self->{device}->get_object_name . ": error during scan callback $@") - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } elsif ($action eq "check" && ((&main::get_tickcount - $self->scandatetime()) <= 2000)){ @@ -160,7 +160,7 @@ sub query_aldb_delta $self->{_aldb_unchanged_callback} = undef; eval ($callback); &::print_log("[Insteon::AllLinkDatabase] " . $self->{device}->get_object_name . ": error during scan callback $@") - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } else { @@ -209,7 +209,6 @@ sub restore_string } $aldb .= $record; } -# &::print_log("[AllLinkDataBase] aldb restore string: $aldb") if $self->debuglevel(); if (defined $self->scandatetime) { $restore_string .= $$self{device}->get_object_name . "->_aldb->scandatetime(q~" . $self->scandatetime . "~) if " @@ -337,7 +336,7 @@ sub delete_link package main; eval($link_parms{callback}); &::print_log("[Insteon::AllLinkDatabase] failure occurred in callback eval for " . $$self{device}->get_object_name . ":" . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } elsif ($link_parms{address} && $link_parms{aldb_check} eq "ok") @@ -395,7 +394,7 @@ sub delete_link package main; eval($link_parms{callback}); &::print_log("[Insteon::AllLinkDatabase] error encountered during delete_link callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDataBase; } } @@ -561,7 +560,7 @@ sub delete_orphan_links if ($group eq '01' || $group eq '00') { #ignore manual responder link to PLM group 01 or 00 required for I2CS devices main::print_log("[Insteon::AllLinkDatabase] DEBUG2 Ignoring orphan responder link from " - . $selfname . " to PLM for group 01 or 00") if $self->debuglevel(2); + . $selfname . " to PLM for group 01 or 00") if $self->{device}->debuglevel(2, 'insteon'); } elsif ($audit_mode) { @@ -857,7 +856,7 @@ sub _process_delete_queue { else { &::print_log("[Insteon::AllLinkDatabase] Nothing else to do for " . $$self{device}->get_object_name . " after deleting " - . $$self{delete_queue_processed} . " links") if $self->debuglevel(); + . $$self{delete_queue_processed} . " links") if $self->{device}->debuglevel(1, 'insteon'); $$self{device}->interface->_aldb->_process_delete_queue($$self{delete_queue_processed}); } } @@ -978,10 +977,10 @@ sub get_first_empty_address } $first_address = ($high_address > 0) ? sprintf('%04x', $high_address - 8) : 0; main::print_log("[Insteon::AllLinkDatabase] DEBUG4: No empty link entries; using next lowest link address [" - .$first_address."]") if $self->debuglevel(4); + .$first_address."]") if $self->{device}->debuglevel(4, 'insteon'); } else { main::print_log("[Insteon::AllLinkDatabase] DEBUG4: Found empty address [" - .$first_address."] in empty array") if $self->debuglevel(4); + .$first_address."] in empty array") if $self->{device}->debuglevel(4, 'insteon'); } return $first_address; @@ -1047,7 +1046,7 @@ sub add_link package main; eval($link_parms{callback}); &::print_log("[Insteon::AllLinkDatabase] failure occurred in callback eval for " . $$self{device}->get_object_name . ":" . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } @@ -1063,7 +1062,7 @@ sub add_link eval($link_parms{callback}); &::print_log("[Insteon::AllLinkDatabase] failure occurred in callback eval for " . $$self{device}->get_object_name . ":" . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } @@ -1086,7 +1085,7 @@ sub add_link &::print_log("[Insteon::AllLinkDatabase] DEBUG2: adding link record " . $$self{device}->get_object_name . " light level controlled by " . $insteon_object->get_object_name . " and group: $group with on level: $on_level and ramp rate: $ramp_rate") - if $self->debuglevel(2); + if $self->{device}->debuglevel(2, 'insteon'); my ($data1, $data2); if($link_parms{is_controller}) { $data1 = '03'; #application retries == 3 @@ -1106,14 +1105,14 @@ sub add_link . $$self{device}->get_object_name . " does not have a record of the first empty ALDB record." . " Please rescan this device's link table") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); if ($$self{_success_callback}) { package main; eval ($$self{_success_callback}); &::print_log("[Insteon::AllLinkDatabase] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } @@ -1145,7 +1144,7 @@ sub update_link my $ramp_rate = $link_parms{ramp_rate}; $ramp_rate =~ s/(\d)s?/$1/; &::print_log("[Insteon::AllLinkDatabase] updating " . $$self{device}->get_object_name . " light level controlled by " . $insteon_object->get_object_name - . " and group: $group with on level: $on_level and ramp rate: $ramp_rate") if $self->debuglevel(); + . " and group: $group with on level: $on_level and ramp rate: $ramp_rate") if $self->{device}->debuglevel(1, 'insteon'); my $data1 = &Insteon::DimmableLight::convert_level($on_level); my $data2 = ($$self{device}->isa('Insteon::DimmableLight')) ? &Insteon::DimmableLight::convert_ramp($ramp_rate) : '00'; my $data3 = ($link_parms{data3}) ? $link_parms{data3} : '00'; @@ -1171,7 +1170,7 @@ sub update_link package main; eval($link_parms{callback}); &::print_log("[Insteon::AllLinkDatabase] failure occurred in callback eval for " . $$self{device}->get_object_name . ":" . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } @@ -1185,14 +1184,14 @@ sub update_link &::print_log("[Insteon::AllLinkDatabase] ERROR: updating link record failed because " . $$self{device}->get_object_name . " does not have an existing ALDB entry key=$key") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); if ($$self{_success_callback}) { package main; eval ($$self{_success_callback}); &::print_log("[Insteon::AllLinkDatabase] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::AllLinkDatabase; } } @@ -1362,18 +1361,6 @@ sub has_link return (defined $$self{aldb}{$key}); } -=item C - -Returns 1 if Insteon or this device is at least debug level 'level', otherwise returns 0. - -=cut - -sub debuglevel -{ - my ($self, $debug_level) = @_; - return Insteon::debuglevel(undef, $debug_level); -} - =back =head2 INI PARAMETERS @@ -1592,7 +1579,7 @@ sub _on_peek my $message = new Insteon::InsteonMessage('insteon_send', $$self{device}, 'peek'); if ($msg{is_extended}) { &::print_log("[Insteon::ALDB_i1]: extended peek for " . $$self{device}->{object_name} - . " is " . $msg{extra}) if $self->debuglevel(); + . " is " . $msg{extra}) if $self->{device}->debuglevel(1, 'insteon'); } else { @@ -1644,7 +1631,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); my $flag = hex($msg{extra}); $$self{pending_aldb}{inuse} = ($flag & 0x80) ? 1 : 0; $$self{pending_aldb}{is_controller} = ($flag & 0x40) ? 1 : 0; @@ -1674,7 +1661,7 @@ sub _on_peek } &::print_log("[Insteon::ALDB_i1] " . $$self{device}->get_object_name . " completed link memory scan") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $self->health("good"); # Put the new ALDB Delta into memory $self->query_aldb_delta('set'); @@ -1724,7 +1711,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{group} = lc $msg{extra}; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{_mem_action} = 'aldb_devhi'; @@ -1744,7 +1731,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{deviceid} = lc $msg{extra}; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{_mem_action} = 'aldb_devmid'; @@ -1765,7 +1752,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{deviceid} .= lc $msg{extra}; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{_mem_action} = 'aldb_devlo'; @@ -1786,7 +1773,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{deviceid} .= lc $msg{extra}; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{_mem_action} = 'aldb_data1'; @@ -1809,7 +1796,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{_mem_action} = 'aldb_data2'; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{pending_aldb}{data1} = $msg{extra}; @@ -1832,7 +1819,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{data2} = $msg{extra}; $$self{_mem_lsb} = sprintf("%02X", hex($$self{_mem_lsb}) + 1); $$self{_mem_action} = 'aldb_data3'; @@ -1855,7 +1842,7 @@ sub _on_peek { &::print_log("[Insteon::ALDB_i1] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{pending_aldb}{data3} = $msg{extra}; if ($$self{_stress_test_act}){ @@ -1937,7 +1924,7 @@ sub _on_peek else { ::print_log("[Insteon::ALDB_i1] " . $$self{device}->get_object_name . ": unhandled _mem_action=".$$self{_mem_action}) - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); } } } @@ -2020,7 +2007,7 @@ sub _write_link if (($$self{device}->isa('Insteon::KeyPadLincRelay') or $$self{device}->isa('Insteon::KeyPadLinc')) and ($data3 eq '00')) { &::print_log("[Insteon::ALDB_i1] setting data3 to " . $$self{device}->group . " for this keypadlinc") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $data3 = $$self{device}->group; } $$self{pending_aldb}{data3} = (defined $data3) ? lc $data3 : '00'; @@ -2036,7 +2023,7 @@ sub _write_link package main; eval ($$self{_success_callback}); &::print_log("[Insteon::ALDB_i1] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::ALDB_i1; } } @@ -2144,7 +2131,7 @@ sub on_read_write_aldb &::print_log("[Insteon::ALDB_i2] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " . lc $msg{extra} . " for _mem_activity=".$$self{_mem_activity} - ." _mem_action=". $$self{_mem_action}) if $self->debuglevel(3); + ." _mem_action=". $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); if ($$self{_mem_action} eq 'aldb_i2read') { @@ -2156,12 +2143,12 @@ sub on_read_write_aldb $$self{_mem_action} = 'aldb_i2readack'; &::print_log("[Insteon::ALDB_i2] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received ack") - if $self->debuglevel(3); + if $self->{device}->debuglevel(3, 'insteon'); } else { #otherwise just ignore the message because it is out of sequence &::print_log("[Insteon::ALDB_i2] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] ack not received. " - . "ignoring message") if $self->debuglevel(3); + . "ignoring message") if $self->{device}->debuglevel(3, 'insteon'); } } @@ -2170,14 +2157,14 @@ sub on_read_write_aldb if($msg{is_ack}) { &::print_log("[Insteon::ALDB_i2] DEBUG3: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received duplicate ack. Ignoring.") - if $self->debuglevel(3); + if $self->{device}->debuglevel(3, 'insteon'); $clear_message = 0; } elsif(length($msg{extra})<30) { &::print_log("[Insteon::ALDB_i2] WARNING: Corrupted I2 response not processed: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{device}->corrupt_count_log(1) if $$self{device}->can('corrupt_count_log'); #can't clear message, if valid message doesn't arrive #resend logic will kick in @@ -2188,7 +2175,7 @@ sub on_read_write_aldb . " address received did not match address requested: " . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " - . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->debuglevel(3); + . lc $msg{extra} . " for " . $$self{_mem_action}) if $self->{device}->debuglevel(3, 'insteon'); $$self{device}->corrupt_count_log(1) if $$self{device}->can('corrupt_count_log'); #can't clear message, if valid message doesn't arrive #resend logic will kick in @@ -2206,7 +2193,7 @@ sub on_read_write_aldb if (lc $$self{_mem_msb} eq '00' and lc $$self{_mem_lsb} eq '00') { main::print_log("[Insteon::ALDB_i2] DEBUG4: Start of scan; initializing aldb structure") - if $self->debuglevel(4); + if $self->{device}->debuglevel(4, 'insteon'); # reinit the aldb hash as there will be a new one $$self{aldb} = undef; # reinit the empty address list @@ -2248,10 +2235,10 @@ sub on_read_write_aldb . $$self{device}->get_object_name . " [0x" . $$self{_mem_msb} . $$self{_mem_lsb} . "] received: " . lc $msg{extra} . " for " . $$self{_mem_action}) - if(($$self{pending_aldb}{inuse}) and $self->debuglevel(3)); + if(($$self{pending_aldb}{inuse}) and $self->{device}->debuglevel(3, 'insteon')); main::print_log("[Insteon::ALDB_i2] DEBUG4: scan done; adding last address [" . $$self{_mem_msb} . $$self{_mem_lsb} ."] to empty array") - if $self->debuglevel(4); + if $self->{device}->debuglevel(4, 'insteon'); $self->add_empty_address($$self{_mem_msb} . $$self{_mem_lsb}); # scan done; clear out state flags $$self{_mem_action} = undef; @@ -2268,7 +2255,7 @@ sub on_read_write_aldb &::print_log("[Insteon::ALDB_i2] " . $$self{device}->get_object_name . " completed link memory scan: status: " . $self->health()) - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $self->health("good"); # Put the new ALDB Delta into memory $self->query_aldb_delta('set'); @@ -2279,7 +2266,7 @@ sub on_read_write_aldb { main::print_log("[Insteon::ALDB_i2] DEBUG4: inuse flag == false; adding address [" . $$self{_mem_msb} . $$self{_mem_lsb} ."] to empty array") - if $self->debuglevel(4); + if $self->{device}->debuglevel(4, 'insteon'); $self->add_empty_address($$self{pending_aldb}{address}); } else @@ -2305,14 +2292,14 @@ sub on_read_write_aldb { main::print_log("[Insteon::ALDB_i2] DEBUG4: duplicate link found; adding address [" . $$self{_mem_msb} . $$self{_mem_lsb} ."] to duplicates array") - if $self->debuglevel(4); + if $self->{device}->debuglevel(4, 'insteon'); $self->add_duplicate_link_address($$self{pending_aldb}{address}); } else { main::print_log("[Insteon::ALDB_i2] DEBUG4: active link found; adding address [" . $$self{_mem_msb} . $$self{_mem_lsb} ."] to aldb") - if $self->debuglevel(4); + if $self->{device}->debuglevel(4, 'insteon'); %{$$self{aldb}{$aldbkey}} = %{$$self{pending_aldb}}; } } @@ -2352,7 +2339,7 @@ sub on_read_write_aldb $$self{pending_aldb} = undef; main::print_log("[Insteon::ALDB_i2] DEBUG3: " . $$self{device}->get_object_name . " link write completed for [".$$self{aldb}{$aldbkey}{address}."]") - if $self->debuglevel(3); + if $self->{device}->debuglevel(3, 'insteon'); $self->health("good"); # Put the new ALDB Delta into memory $self->query_aldb_delta('set'); @@ -2385,7 +2372,7 @@ sub on_read_write_aldb { main::print_log("[Insteon::ALDB_i2] " . $$self{device}->get_object_name . ": unhandled _mem_action=".$$self{_mem_action}) - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $clear_message = 0; } return $clear_message; @@ -2432,7 +2419,7 @@ sub _write_link if (($$self{device}->isa('Insteon::KeyPadLincRelay') or $$self{device}->isa('Insteon::KeyPadLinc')) and ($data3 eq '00')) { &::print_log("[Insteon::ALDB_i2] setting data3 to " . $$self{device}->group . " for this keypadlinc") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $data3 = $$self{device}->group; } $$self{pending_aldb}{data3} = (defined $data3) ? lc $data3 : '00'; @@ -2453,7 +2440,7 @@ sub _write_link package main; eval ($$self{_success_callback}); &::print_log("[Insteon::ALDB_i2] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::ALDB_i2; } } @@ -2503,7 +2490,7 @@ sub _write_delete package main; eval ($$self{_success_callback}); &::print_log("[Insteon::ALDB_i2] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon::ALDB_i2; } } @@ -2783,7 +2770,7 @@ sub delete_orphan_links &::print_log("[Insteon::ALDB_PLM] (AUDIT) Delete Orphan Link to non-existant deviceid: " . $deviceid . "; group:$group; " . (($is_controller) ? "controller; data:$data3" : "responder")) - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); } else { @@ -2808,13 +2795,13 @@ sub delete_orphan_links if ($group eq '01' || $group eq '00') { #ignore manual controller link from PLM group 01 or 00 to device required for I2CS devices main::print_log("[Insteon::ALDB_PLM] DEBUG2 Ignoring orphan PLM controller(01 or 00) link to " - . $device->get_object_name() ) if $self->debuglevel(2); + . $device->get_object_name() ) if $self->{device}->debuglevel(2, 'insteon'); } elsif ($audit_mode) { &::print_log("[Insteon::ALDB_PLM] (AUDIT) Delete Orphan PLM controller link ($group) to: " . $device->get_object_name() . "($data3)") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); } else { @@ -2938,7 +2925,7 @@ sub _process_delete_queue { . (($delete_req{is_controller}) ? "controller($delete_req{data3})" : "responder") . ", " . (($delete_req{object}) ? "object=" . $delete_req{object}->get_object_name : "deviceid=$delete_req{deviceid}") . ", group=$delete_req{group}") - if $self->debuglevel(); + if $self->{device}->debuglevel(1, 'insteon'); $self->delete_link(%delete_req); } elsif ($delete_req{linkdevice}) @@ -3008,7 +2995,7 @@ sub delete_link package main; eval ($link_parms{callback}); &::print_log("[Insteon_PLM] error in add link callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon_PLM; } } @@ -3059,7 +3046,7 @@ sub add_link package main; eval ($link_parms{callback}); &::print_log("[Insteon::ALDB_PLM] error in add link callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->{device}->debuglevel(1, 'insteon'); package Insteon_PLM; } } diff --git a/lib/Insteon/BaseInsteon.pm b/lib/Insteon/BaseInsteon.pm index faeb92099..b569c1df1 100644 --- a/lib/Insteon/BaseInsteon.pm +++ b/lib/Insteon/BaseInsteon.pm @@ -206,18 +206,6 @@ sub group return $$self{m_group}; } -=item C - -Returns 1 if insteon or this device is at least debug level 'level', otherwise returns 0. - -=cut - -sub debuglevel -{ - my ($self, $debug_level) = @_; - return Insteon::debuglevel($self, $debug_level); -} - =item C Changes the amount of time MH will wait to receive a response from a device before @@ -285,7 +273,7 @@ sub default_hop_count my ($self, $hop_count) = @_; if (defined($hop_count)){ ::print_log("[Insteon::BaseObject] DEBUG3: Adding hop count of " . $hop_count . " to hop_array of " - . $self->get_object_name) if $self->debuglevel(3); + . $self->get_object_name) if $self->debuglevel(3, 'insteon'); if (!defined(@{$$self{hop_array}})) { unshift(@{$$self{hop_array}}, $$self{default_hop_count}); $$self{hop_sum} = $$self{default_hop_count}; @@ -299,7 +287,7 @@ sub default_hop_count ::print_log("[Insteon::BaseObject] DEBUG4: ".$self->get_object_name ."->default_hop_count()=".$$self{default_hop_count} ." :: hop_array[]=". join("",@{$$self{hop_array}})) - if $self->debuglevel(4); + if $self->debuglevel(4, 'insteon'); } #Allow for per-device settings @@ -380,14 +368,14 @@ sub set { #If set by device, update MH state, my $derived_state = $self->derive_link_state($p_state); &::print_log("[Insteon::BaseObject] " . $self->get_object_name() - . "::set_receive($derived_state, $setby_name)") if $self->debuglevel(); + . "::set_receive($derived_state, $setby_name)") if $self->debuglevel(1, 'insteon'); $self->set_receive($derived_state,$p_setby,$p_response); $self->set_linked_devices($p_state); } elsif (ref $p_setby and $p_setby eq $self->interface) { #If set by interface, this was a manual status_request response &::print_log("[Insteon::BaseObject] " . $self->get_object_name() - . "::set_receive($p_state, $setby_name)") if $self->debuglevel(); + . "::set_receive($p_state, $setby_name)") if $self->debuglevel(1, 'insteon'); $self->set_receive($p_state,$p_setby,$p_response); } else { # Not called by device, send set command @@ -395,7 +383,7 @@ sub set my $message = $self->derive_message($p_state); $self->_send_cmd($message); &::print_log("[Insteon::BaseObject] " . $self->get_object_name() . "::set($p_state, $setby_name)") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); $self->is_acknowledged(0); $$self{pending_state} = $p_state; $$self{pending_setby} = $p_setby; @@ -461,7 +449,7 @@ sub set_receive && ($curr_milli - $$self{set_milliseconds} < $window)){ ::print_log("[Insteon::BaseObject] Ignoring duplicate set " . $p_state . " state command for " . $self->get_object_name . " received in " . - "less than $window milliseconds") if $self->debuglevel(); + "less than $window milliseconds") if $self->debuglevel(1, 'insteon'); } else { $$self{set_milliseconds} = $curr_milli; $self->level($p_state) if $self->can('level'); # update the level value @@ -585,7 +573,7 @@ sub derive_message # confirm that the resulting $msg is legitimate if (!(defined($self->message_type_code($command)))) { - &::print_log("[Insteon::BaseInsteon] invalid state=$command") if $self->debuglevel(); + &::print_log("[Insteon::BaseInsteon] invalid state=$command") if $self->debuglevel(1, 'insteon'); return undef; } @@ -669,7 +657,7 @@ sub _is_info_request my $ack_on_level = sprintf("%d", int((hex($msg{extra}) * 100 / 255)+.5)); &::print_log("[Insteon::BaseObject] received status for " . $self->{object_name} . " with on-level: $ack_on_level%, " - . "hops left: $msg{hopsleft}") if $self->debuglevel(); + . "hops left: $msg{hopsleft}") if $self->debuglevel(1, 'insteon'); $self->level($ack_on_level) if $self->can('level'); # update the level value if ($ack_on_level == 0) { $self->set('off', $ack_setby); @@ -727,7 +715,7 @@ sub _is_info_request package main; eval ($callback); &::print_log("[Insteon::BaseObject] " . $self->get_object_name . ": error during scan callback $@") - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon::BaseObject; } } @@ -738,7 +726,7 @@ sub _is_info_request $self->engine_version($version); &::print_log("[Insteon::BaseObject] received engine version for " . $self->{object_name} . " of $version. " - . "hops left: $msg{hopsleft}") if $self->debuglevel(); + . "hops left: $msg{hopsleft}") if $self->debuglevel(1, 'insteon'); } return $is_info_request; } @@ -755,7 +743,7 @@ sub _process_message # by Insteon_Link. main::print_log("[Insteon::BaseObject] WARN: Message has invalid checksum") - if ($self->debuglevel() && !($msg{crc_valid}) + if ($self->debuglevel(1, 'insteon') && !($msg{crc_valid}) && $msg{is_extended} && $self->engine_version() eq 'I2CS'); my $clear_message = 0; @@ -821,7 +809,7 @@ sub _process_message if (!$corrupt_cmd){ $self->_process_command_stack(%msg); &::print_log("[Insteon::BaseObject] received ping acknowledgement from " . $self->{object_name}) - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); $self->ping(); $clear_message = 1; } @@ -830,7 +818,7 @@ sub _process_message $corrupt_cmd = 1 if ($msg{cmd_code} ne $self->message_type_hex($pending_cmd)); if (!$corrupt_cmd){ &::print_log("[Insteon::BaseObject] received linking mode ACK from " . $self->{object_name}) - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); $self->interface->_set_timeout('xmit', 2000); $clear_message = 0; } @@ -847,7 +835,7 @@ sub _process_message # signal receipt of message to the command stack in case commands are queued $self->_process_command_stack(%msg); &::print_log("[Insteon::BaseObject] received command/state (awaiting) acknowledge from " . $self->{object_name} - . ": $pending_cmd and data: $msg{extra}") if $self->debuglevel(); + . ": $pending_cmd and data: $msg{extra}") if $self->debuglevel(1, 'insteon'); } } else @@ -859,7 +847,7 @@ sub _process_message $self->_process_command_stack(%msg); &::print_log("[Insteon::BaseObject] received command/state acknowledge from " . $self->{object_name} . ": " . (($msg{command}) ? $msg{command} : "(unknown)") - . " and data: $msg{extra}") if $self->debuglevel(); + . " and data: $msg{extra}") if $self->debuglevel(1, 'insteon'); } if ($corrupt_cmd) { main::print_log("[Insteon::BaseObject] WARN: received a message from " @@ -879,7 +867,7 @@ sub _process_message . $self->get_nack_msg_for( $msg{extra} ) .") for " . $self->{object_name} . ". It may be unplugged, have a burned out bulb, or this may be a new I2CS " . "type device that must first be manually linked to the PLM using the set button.") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); } else { @@ -893,7 +881,7 @@ sub _process_message if($p_setby->active_message->failure_callback) { main::print_log("[Insteon::BaseObject] WARN: Now calling message failure callback: " - . $p_setby->active_message->failure_callback) if $self->debuglevel(); + . $p_setby->active_message->failure_callback) if $self->debuglevel(1, 'insteon'); $self->failure_reason('NAK'); package main; eval $p_setby->active_message->failure_callback; @@ -937,7 +925,7 @@ sub _process_message if ($msg{command} eq 'link_cleanup_report'){ if ($msg{extra} == 0){ ::print_log("[Insteon::BaseObject] DEBUG Received AllLink Cleanup Success for " - . $self->{object_name}) if $self->debuglevel(1); + . $self->{object_name}) if $self->debuglevel(1, 'insteon'); } else { ::print_log("[Insteon::BaseObject] WARN " . $msg{extra} . " Device(s) failed to " . "acknowledge the command from " . $self->{object_name}); @@ -953,7 +941,7 @@ sub _process_message my $timeout = (scalar(@links)+1) * 300; ::print_log("[Insteon::BaseObject] DEBUG3 Delaying any outgoing messages ". "by $timeout milliseconds to avoid collision with subsequent cleanup ". - "messages from " . $self->get_object_name) if ($self->debuglevel(3)); + "messages from " . $self->get_object_name) if ($self->debuglevel(3, 'insteon')); $self->interface->_set_timeout('xmit', $timeout); } } @@ -962,14 +950,14 @@ sub _process_message if (($self->state eq $p_state or $self->state_final eq $p_state) and $$self{_pending_cleanup}){ ::print_log("[Insteon::BaseObject] Ignoring Received Direct AllLink Cleanup Message for " - . $self->{object_name} . " since AllLink Broadcast Message was Received.") if $self->debuglevel(); + . $self->{object_name} . " since AllLink Broadcast Message was Received.") if $self->debuglevel(1, 'insteon'); } else { $self->set($p_state, $self); } $$self{_pending_cleanup} = 0; } else { main::print_log("[Insteon::BaseObject] Ignoring unsupported command from " - . $self->{object_name}) if $self->debuglevel(); + . $self->{object_name}) if $self->debuglevel(1, 'insteon'); $self->corrupt_count_log(1) if $self->can('corrupt_count_log'); } } @@ -1032,11 +1020,11 @@ sub _process_command_stack package main; eval ($callback); &::print_log("[Insteon::BaseObject] error in queue timer callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon::BaseObject; } } else { -# &::print_log("[Insteon_Device] " . $self->get_object_name . " command queued but not yet sent; awaiting ack from prior command") if $self->debuglevel(); +# &::print_log("[Insteon_Device] " . $self->get_object_name . " command queued but not yet sent; awaiting ack from prior command") if $self->debuglevel(1, 'insteon'); } } @@ -1980,7 +1968,7 @@ sub _get_engine_version_failure my $failure_reason = $self->failure_reason(); main::print_log("[Insteon::BaseDevice::_get_engine_version_failure] DEBUG4: " - ."failure reason: $failure_reason") if $self->debuglevel(4); + ."failure reason: $failure_reason") if $self->debuglevel(4, 'insteon'); if($failure_reason eq 'NAK') { @@ -2046,7 +2034,7 @@ sub ping package main; eval ($complete_callback); &::print_log("[Insteon::BaseDevice] error in ping callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon::BaseDevice; delete $$self{ping_callback}; } @@ -2352,7 +2340,7 @@ sub stress_test package main; eval ($complete_callback); &::print_log("[Insteon::BaseDevice] error in stress_test callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon::BaseDevice; delete $$self{stress_test_callback}; } @@ -2667,7 +2655,7 @@ sub check_aldb_version if ($new_version) { main::print_log("[Insteon::BaseDevice] DEBUG4: aldb_version is " .$self->_aldb->aldb_version()." but device is ".$engine_version. - ". Remapping aldb version to $new_version") if $self->debuglevel(4); + ". Remapping aldb version to $new_version") if $self->debuglevel(4, 'insteon'); my $restore_string = ''; if ($self->_aldb) { $restore_string = $self->_aldb->restore_string(); @@ -2684,7 +2672,7 @@ sub check_aldb_version package main; eval ($restore_string); &::print_log("[Insteon::BaseDevice] error in eval creating ALDB object: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon::BaseDevice; } } @@ -2936,7 +2924,7 @@ sub sync_links $requires_update = 1; &::print_log("[Insteon::BaseController] DEBUG: flagging " . $self->get_object_name . " for update because existing ramp rate ($raw_ramp_rate) != target ($raw_tgt_ramp_rate)") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); } elsif (($link_on_level > $tgt_on_level + 1) or ($link_on_level < $tgt_on_level -1)) @@ -2944,7 +2932,7 @@ sub sync_links $requires_update = 1; &::print_log("[Insteon::BaseController] DEBUG: flagging " . $self->get_object_name . " for update because existing on level ($link_on_level) != target ($tgt_on_level)") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); } } if ($requires_update) @@ -2971,7 +2959,7 @@ sub sync_links . $member->get_object_name . " for " . $insteon_object->get_object_name . " with group:" . $self->group . "; on_level:$tgt_on_level; ramp_rate:$tgt_ramp_rate") - if $self->debuglevel(4); + if $self->debuglevel(4, 'insteon'); push @{$$self{sync_queue}}, \%link_req; } } @@ -3000,7 +2988,7 @@ sub sync_links . $member->get_object_name . " for " . $insteon_object->get_object_name . " with group:" . $self->group . "; on_level:$tgt_on_level; ramp_rate:$tgt_ramp_rate") - if $self->debuglevel(4); + if $self->debuglevel(4, 'insteon'); push @{$$self{sync_queue}}, \%link_req; } } @@ -3024,7 +3012,7 @@ sub sync_links } main::print_log("[Insteon::BaseController] DEBUG4: queuing add for controller record to " . $insteon_object->get_object_name . " for " . $member->get_object_name - . " with group:" . $self->group) if $self->debuglevel(4); + . " with group:" . $self->group) if $self->debuglevel(4, 'insteon'); push @{$$self{sync_queue}}, \%link_req; } } @@ -3052,7 +3040,7 @@ sub sync_links main::print_log("[Insteon::BaseController] DEBUG4: queuing add for controller record to " . $insteon_object->get_object_name . " for " . $self->interface->get_object_name . " with group:" . $self->group) - if $self->debuglevel(4); + if $self->debuglevel(4, 'insteon'); push @{$$self{sync_queue}}, \%link_req; } } @@ -3073,7 +3061,7 @@ sub sync_links main::print_log("[Insteon::BaseController] DEBUG4: queuing add for responder record to " . $self->interface->get_object_name . " for " . $insteon_object->get_object_name . " with group:" . $self->group) - if $self->debuglevel(4); + if $self->debuglevel(4, 'insteon'); push @{$$self{sync_queue}}, \%link_req; } } @@ -3082,7 +3070,7 @@ sub sync_links if (!($num_sync_queue)) { &::print_log("[Insteon::BaseController] Nothing to do when syncing links for " . $self->get_object_name) - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); } $self->_process_sync_queue(); @@ -3109,7 +3097,7 @@ sub _process_sync_queue { package main; eval ($$self{sync_queue_callback}); &::print_log("[Insteon::BaseController] error in sync links callback: " . $@) - if $@ and $self->debuglevel(); + if $@ and $self->debuglevel(1, 'insteon'); $$self{sync_queue_callback} = undef; package Insteon::BaseController; } else { @@ -3243,7 +3231,7 @@ sub update_members my %current_record = $device->get_link_record($self->device_id . $self->group); if (%current_record) { &::print_log("[Insteon::BaseController] remote record: $current_record{data1}") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); } } } diff --git a/lib/Insteon/BaseInterface.pm b/lib/Insteon/BaseInterface.pm index 85ab3b813..d1b70eccb 100644 --- a/lib/Insteon/BaseInterface.pm +++ b/lib/Insteon/BaseInterface.pm @@ -128,8 +128,8 @@ Returns 1 if Insteon or this device is at least debug level 'level', otherwise r sub debuglevel { - my ($self, $debug_level) = @_; - return Insteon::debuglevel($self, $debug_level); + my ($self, $debug_level, $debug_group) = @_; + return Generic_Item::debuglevel($self, $debug_level, $debug_group); } =item C<_is_duplicate(cmd)> @@ -308,7 +308,7 @@ sub queue_message my $setby = $message->setby; if ($self->_is_duplicate($message->interface_data) && !($message->isa('Insteon::X10Message'))) { - &main::print_log("[Insteon::BaseInterface] Attempt to queue command already in queue; skipping ...") if $self->debuglevel(); + &main::print_log("[Insteon::BaseInterface] Attempt to queue command already in queue; skipping ...") if $self->debuglevel(1, 'insteon'); } else { @@ -366,7 +366,7 @@ sub process_queue &::print_log("[Insteon::BaseInterface] WARN: number of retries (" . $self->active_message->send_attempts . ") for " . $self->active_message->to_string() - . " exceeds limit. Now moving on...") if $self->debuglevel(); + . " exceeds limit. Now moving on...") if $self->debuglevel(1, 'insteon'); # !!!!!!!!! TO-DO - handle failure timeout ??? my $failed_message = $self->active_message; # make sure to let the sending object know!!! @@ -387,7 +387,7 @@ sub process_queue if ($failed_message->failure_callback) { &::print_log("[Insteon::BaseInterface] WARN: Message Timeout: Now calling callback: " . - $failed_message->failure_callback) if $self->debuglevel(); + $failed_message->failure_callback) if $self->debuglevel(1, 'insteon'); $failed_message->setby->failure_reason('timeout') if (defined($failed_message->setby) and $failed_message->setby->can('failure_reason')); package main; @@ -500,7 +500,7 @@ sub on_interface_info_received my ($self) = @_; &::print_log("[Insteon_PLM] PLM id: " . $self->device_id . " firmware: " . $self->firmware) - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); $self->clear_active_message(); } @@ -533,7 +533,7 @@ sub on_standard_insteon_received #time has been required. Extra 50 millis helps prevent dupes $wait_time = ($wait_time * 100) + 50; $wait_message .= "delaying next transmit by $wait_time milliseconds to avoid collisions."; - ::print_log($wait_message) if ($self->debuglevel(3) && $wait_time > 50); + ::print_log($wait_message) if ($self->debuglevel(3, 'insteon') && $wait_time > 50); $self->_set_timeout('xmit', $wait_time); # get the matching object @@ -548,13 +548,13 @@ sub on_standard_insteon_received $msg{command} = $object->message_type($msg{cmd_code}); &::print_log("[Insteon::BaseInterface] Received message from: ". $object->get_object_name ."; command: $msg{command}; type: $msg{type}; group: $msg{group}") - if (!($msg{is_ack} or $msg{is_nack})) and $self->debuglevel(); + if (!($msg{is_ack} or $msg{is_nack})) and $self->debuglevel(1, 'insteon'); } if ($msg{is_ack} or $msg{is_nack}) { main::print_log("[Insteon::BaseInterface] DEBUG3: PLM command:insteon_received; " . "Device command:$msg{command}; type:$msg{type}; group: $msg{group}") - if $self->debuglevel(3); + if $self->debuglevel(3, 'insteon'); # need to confirm that this message corresponds to the current active one before clearing it # TO-DO!!! This is a brute force and poor compare technique; needs to be replaced by full compare if ($self->active_message && ref $self->active_message->setby) @@ -576,7 +576,7 @@ sub on_standard_insteon_received if($object->_process_message($self, %msg)) { if ($self->active_message->success_callback){ main::print_log("[Insteon::BaseInterface] DEBUG4: Now calling message success callback: " - . $self->active_message->success_callback) if $self->debuglevel(4); + . $self->active_message->success_callback) if $object->debuglevel(4, 'insteon'); package main; eval $self->active_message->success_callback; ::print_log("[Insteon::BaseInterface] problem w/ success callback: $@") if $@; @@ -606,11 +606,11 @@ sub on_standard_insteon_received if (($msg{extra} == $self->active_message->setby->group)){ &main::print_log("[Insteon::BaseInterface] DEBUG3: Cleanup message received for scene " . $object->get_object_name . " from " . $setby_object->get_object_name) - if $self->debuglevel(3); + if $object->debuglevel(3, 'insteon'); } elsif ($self->active_message->command_type eq 'all_link_direct_cleanup' && lc($self->active_message->setby->device_id) eq $msg{source}) { - &::print_log("[Insteon::BaseInterface] DEBUG2: ALL-Linking Direct Completed with ". $self->active_message->setby->get_object_name) if $self->debuglevel(2); + &::print_log("[Insteon::BaseInterface] DEBUG2: ALL-Linking Direct Completed with ". $self->active_message->setby->get_object_name) if $object->debuglevel(2, 'insteon'); $self->clear_active_message(); } else { @@ -619,7 +619,7 @@ sub on_standard_insteon_received . $object->get_object_name . ", but group in recent message " . $msg{extra}. " did not match group in " . "prior sent message group " . $self->active_message->setby->group) - if $self->debuglevel(3); + if $object->debuglevel(3, 'insteon'); } # If ACK or NACK received then PLM is still working on the ALL Link Command # Increase the command timeout to wait for next one @@ -655,9 +655,13 @@ sub on_standard_insteon_received # in the Insteon_PLM handler for cleanup messages. # however, if the virtual handler was not invoked due to receipt of the broadcast message # then, the above cleanup handler would be run + my $plm_group_obj = Insteon::get_object('000000', $msg{extra}); + my $group_name = $msg{extra}; + $group_name = $plm_group_obj->get_object_name if (ref $plm_group_obj); + $plm_group_obj = $self if (!ref $plm_group_obj); &main::print_log("[Insteon::BaseInterface] DEBUG3: received cleanup message responding to " - . "PLM controller group: $msg{extra}. Ignoring as this has already been processed") - if $self->debuglevel(3); + . "PLM controller group: $group_name. Ignoring as this has already been processed") + if $plm_group_obj->debuglevel(3, 'insteon'); } else { @@ -710,7 +714,7 @@ sub on_extended_insteon_received #time has been required. Extra 50 millis helps prevent dupes $wait_time = ($wait_time * 200) + 50; $wait_message .= "delaying next transmit by $wait_time milliseconds to avoid collisions."; - ::print_log($wait_message) if ($self->debuglevel(3) && $wait_time > 50); + ::print_log($wait_message) if ($self->debuglevel(3, 'insteon') && $wait_time > 50); $self->_set_timeout('xmit', $wait_time); # get the matching object @@ -725,14 +729,14 @@ sub on_extended_insteon_received $msg{command} = $object->message_type($msg{cmd_code}); main::print_log("[Insteon::BaseInterface] DEBUG: PLM command:insteon_ext_received; " . "Device command:$msg{command}; type:$msg{type}; group: $msg{group}") - if( (!($msg{is_ack} or $msg{is_nack}) and $self->debuglevel()) - or $self->debuglevel(3)); + if( (!($msg{is_ack} or $msg{is_nack}) and $self->debuglevel(1, 'insteon')) + or $self->debuglevel(3, 'insteon')); } - &::print_log("[Insteon::BaseInterface] Processing message for " . $object->get_object_name) if $self->debuglevel(3); + &::print_log("[Insteon::BaseInterface] Processing message for " . $object->get_object_name) if $object->debuglevel(3, 'insteon'); if($object->_process_message($self, %msg)) { if (ref $self->active_message && $self->active_message->success_callback){ main::print_log("[Insteon::BaseInterface] DEBUG4: Now calling message success callback: " - . $self->active_message->success_callback) if $self->debuglevel(4); + . $self->active_message->success_callback) if $object->debuglevel(4, 'insteon'); package main; eval $self->active_message->success_callback; ::print_log("[Insteon::BaseInterface] problem w/ success callback: $@") if $@; @@ -891,7 +895,7 @@ sub _is_duplicate_received { $object->default_hop_count($msg{maxhops}-$msg{hopsleft}) if $object->can('default_hop_count'); }; ::print_log("[Insteon::BaseInterface] WARN! Dropped duplicate incoming message " - . $message_data . ", from $source.") if $self->debuglevel(); + . $message_data . ", from ". $object->get_object_name) if $object->debuglevel(1, 'insteon'); } else { #Message was not in hash, so add it $$self{received_commands}{$key} = $curr_milli + $delay; diff --git a/lib/Insteon/Controller.pm b/lib/Insteon/Controller.pm index 6a9958855..89f58e777 100644 --- a/lib/Insteon/Controller.pm +++ b/lib/Insteon/Controller.pm @@ -209,9 +209,9 @@ sub _process_message { elsif ($msg{command} eq "extended_set_get" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); #If this was a get request don't clear until data packet received - main::print_log("[Insteon::RemoteLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::RemoteLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); if ($$self{_ext_set_get_action} eq 'set'){ - main::print_log("[Insteon::RemoteLinc] Clearing active message") if $self->debuglevel(); + main::print_log("[Insteon::RemoteLinc] Clearing active message") if $self->debuglevel(1, 'insteon'); $clear_message = 1; $$self{_ext_set_get_action} = undef; $self->_process_command_stack(%msg); @@ -234,7 +234,7 @@ sub _process_message { $self->_process_command_stack(%msg); } else { main::print_log("[Insteon::RemoteLinc] WARN: Corrupt Extended " - ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(); + ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); } } else { diff --git a/lib/Insteon/IOLinc.pm b/lib/Insteon/IOLinc.pm index 92b94876b..0349011c1 100755 --- a/lib/Insteon/IOLinc.pm +++ b/lib/Insteon/IOLinc.pm @@ -158,11 +158,11 @@ sub set if ($p_state eq $$self{child_state} && ($curr_milli - $$self{child_set_milliseconds} < $window)) { ::print_log("[Insteon::IOLinc] Received duplicate ". $self->get_object_name - . " sensor " . $p_state . " message, ignoring.") if $self->debuglevel(); + . " sensor " . $p_state . " message, ignoring.") if $self->debuglevel(1, 'insteon'); } else { ::print_log("[Insteon::IOLinc] Received ". $self->get_object_name - . " sensor " . $p_state . " message.") if $self->debuglevel(); + . " sensor " . $p_state . " message.") if $self->debuglevel(1, 'insteon'); $$self{child_state} = $p_state; $$self{child_set_milliseconds} = $curr_milli; if (ref $$self{child_sensor}){ @@ -213,7 +213,7 @@ sub _is_info_request my $child_state = &Insteon::BaseObject::derive_link_state(hex($msg{extra})); &::print_log("[Insteon::IOLinc] received status for " . $self->get_object_name . "sensor of: $child_state " - . "hops left: $msg{hopsleft}") if $self->debuglevel(); + . "hops left: $msg{hopsleft}") if $self->debuglevel(1, 'insteon'); $ack_setby = $$self{child_sensor} if ref $$self{child_sensor}; if (ref $$self{child_sensor}){ $$self{child_sensor}->set_receive($child_state, $ack_setby); @@ -265,9 +265,9 @@ sub _process_message { elsif ($msg{command} eq "extended_set_get" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); #If this was a get request don't clear until data packet received - main::print_log("[Insteon::IOLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::IOLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); if ($$self{_ext_set_get_action} eq 'set'){ - main::print_log("[Insteon::IOLinc] Clearing active message") if $self->debuglevel(); + main::print_log("[Insteon::IOLinc] Clearing active message") if $self->debuglevel(1, 'insteon'); $clear_message = 1; $$self{_ext_set_get_action} = undef; $self->_process_command_stack(%msg); @@ -284,12 +284,12 @@ sub _process_message { $self->_process_command_stack(%msg); } else { main::print_log("[Insteon::IOLinc] WARN: Corrupt Extended " - ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(); + ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); } } elsif ($msg{command} eq "set_operating_flags" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); - main::print_log("[Insteon::IOLinc] Acknowledged flag set for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::IOLinc] Acknowledged flag set for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); $clear_message = 1; $self->_process_command_stack(%msg); } @@ -314,12 +314,12 @@ sub set_momentary_time my $root = $self->get_root(); if ($momentary_time == 0){ ::print_log("[Insteon::IOLinc] Setting " . $self->get_object_name . - " to Latching Relay Mode." ) if $self->debuglevel(); + " to Latching Relay Mode." ) if $self->debuglevel(1, 'insteon'); } elsif ($momentary_time <= 255) { $momentary_time = 2 if $momentary_time == 1; #Can't set to 1 ::print_log("[Insteon::IOLinc] Setting Momentary Time to $momentary_time " . - "tenths of a second for " . $self->get_object_name) if $self->debuglevel(); + "tenths of a second for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); } else { ::print_log("[Insteon::IOLinc] WARN Invalid Momentary Time of $momentary_time " . diff --git a/lib/Insteon/Irrigation.pm b/lib/Insteon/Irrigation.pm index f56b0a957..686586780 100755 --- a/lib/Insteon/Irrigation.pm +++ b/lib/Insteon/Irrigation.pm @@ -128,7 +128,7 @@ sub set_valve { } unless ($cmd and $subcmd) { &::print_log("Insteon::Irrigation] ERROR: You must specify a valve number and a valid state (ON or OFF)") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); return; } my $message = new Insteon::InsteonMessage('insteon_send', $self, $cmd, $subcmd); @@ -154,7 +154,7 @@ sub set_program { } unless ($cmd and $subcmd) { &::print_log("Insteon::Irrigation] ERROR: You must specify a program number and a valid state (ON or OFF)") - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); return; } my $message = new Insteon::InsteonMessage('insteon_send', $self, $cmd, $subcmd); @@ -257,7 +257,7 @@ sub _is_info_request { or $cmd eq 'sprinkler_program_off') { $is_info_request = 1; my $val = hex($msg{extra}); - &::print_log("[Insteon::Irrigation] Processing data for $cmd with value: $val") if $self->debuglevel(); + &::print_log("[Insteon::Irrigation] Processing data for $cmd with value: $val") if $self->debuglevel(1, 'insteon'); $$self{'active_valve_id'} = ($val & 7) + 1; $$self{'active_program_number'} = (($val >> 3) & 3) + 1; $$self{'program_is_running'} = ($val >> 5) & 1; @@ -265,7 +265,7 @@ sub _is_info_request { $$self{'valve_is_running'} = ($val >> 7) & 1; &::print_log("[Insteon::Irrigation] active_valve_id: $$self{'active_valve_id'}," . " valve_is_running: $$self{'valve_is_running'}, active_program: $$self{'active_program_number'}," - . " program_is_running: $$self{'program_is_running'}, pump_enabled: $$self{'pump_enabled'}") if $self->debuglevel(); + . " program_is_running: $$self{'program_is_running'}, pump_enabled: $$self{'pump_enabled'}") if $self->debuglevel(1, 'insteon'); } else { #Check if this was a generic info_request diff --git a/lib/Insteon/Lighting.pm b/lib/Insteon/Lighting.pm index cd12c6b91..070f7a383 100644 --- a/lib/Insteon/Lighting.pm +++ b/lib/Insteon/Lighting.pm @@ -1140,7 +1140,7 @@ sub _is_info_request my $child_state = $child_obj->derive_link_state(hex($msg{extra})); &::print_log("[Insteon::FanLinc] received status for " . $child_obj->{object_name} . " of: $child_state " - . "hops left: $msg{hopsleft}") if $self->debuglevel(); + . "hops left: $msg{hopsleft}") if $self->debuglevel(1, 'insteon'); $ack_setby = $$child_obj{m_status_request_pending} if ref $$child_obj{m_status_request_pending}; $child_obj->SUPER::set($child_state, $ack_setby); delete($$parent{child_status_request_pending}); @@ -1171,7 +1171,7 @@ sub is_acknowledged $$child_obj{pending_setby} = undef; $$child_obj{pending_response} = undef; $$parent{child_pending_state} = undef; - &::print_log("[Insteon::FanLinc] received command/state acknowledge from " . $child_obj->{object_name}) if $self->debuglevel(); + &::print_log("[Insteon::FanLinc] received command/state acknowledge from " . $child_obj->{object_name}) if $self->debuglevel(1, 'insteon'); return $$self{is_acknowledged}; } else { return $self->SUPER::is_acknowledged($p_ack); diff --git a/lib/Insteon/Message.pm b/lib/Insteon/Message.pm index eb95975fd..843547980 100644 --- a/lib/Insteon/Message.pm +++ b/lib/Insteon/Message.pm @@ -136,18 +136,6 @@ sub send_attempts return $$self{send_attempts}; } -=item C - -Returns 1 if Insteon or this device is at least debug level 'level', otherwise returns 0. - -=cut - -sub debuglevel -{ - my ($self, $debug_level) = @_; - return Insteon::debuglevel(undef, $debug_level); -} - =item C Stores and retrieves what the source of this message was. @@ -245,7 +233,7 @@ sub send { &::print_log("[Insteon::BaseMessage] WARN: now resending " . $self->to_string() . " after " . $self->send_attempts - . " attempts.") if $self->debuglevel(); + . " attempts.") if $self->setby->debuglevel(1, 'insteon'); # revise default hop count to reflect retries if (ref $self->setby && $self->setby->isa('Insteon::BaseObject') && !defined($$self{no_hop_increase})) @@ -260,7 +248,7 @@ sub send && $self->setby->isa('Insteon::BaseObject')){ &main::print_log("[Insteon::BaseMessage] Hop count not increased for " . $self->setby->get_object_name . " because no_hop_increase flag was set.") - if $self->debuglevel(); + if $self->setby->debuglevel(1, 'insteon'); $$self{no_hop_increase} = undef; } } @@ -1098,7 +1086,7 @@ sub generate_commands } if ($uc eq undef) { - &main::print_log("[Insteon::Message] Message is for entire HC") if Insteon::debuglevel(undef); + &main::print_log("[Insteon::Message] Message is for entire HC") if (ref $p_setby && $p_setby->debuglevel(1,'insteon')); } else { @@ -1107,7 +1095,7 @@ sub generate_commands $msg.= substr(unpack("H*",pack("C",$x10_unit_codes{substr($id,2,1)})),1,1); $msg.= "00"; &main::print_log("[Insteon_PLM] x10 sending code: " . uc($hc . $uc) . " as insteon msg: " - . $msg) if Insteon::debuglevel(undef); + . $msg) if (ref $p_setby && $p_setby->debuglevel(1,'insteon')); push @data, $msg; } @@ -1135,7 +1123,7 @@ sub generate_commands $msg.= "80"; &main::print_log("[Insteon_PLM] x10 sending code: " . uc($hc . $x10_arg) . " as insteon msg: " - . $msg) if Insteon::debuglevel(undef); + . $msg) if (ref $p_setby && $p_setby->debuglevel(1,'insteon')); push @data, $msg; diff --git a/lib/Insteon/Security.pm b/lib/Insteon/Security.pm index cfdcdfa43..cdd325efd 100644 --- a/lib/Insteon/Security.pm +++ b/lib/Insteon/Security.pm @@ -392,7 +392,7 @@ sub _process_message { elsif ($msg{command} eq "extended_set_get" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); #If this was a get request don't clear until data packet received - main::print_log("[Insteon::MotionSensor] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::MotionSensor] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); if ($$self{_ext_set_get_action} eq 'set'){ if (defined($$root{_set_bit_action})){ ::print_log("[Insteon::MotionSensor] Set of ". @@ -400,7 +400,7 @@ sub _process_message { $root->get_object_name); $$root{_set_bit_action} = undef; } else { - main::print_log("[Insteon::MotionSensor] Clearing active message") if $self->debuglevel(); + main::print_log("[Insteon::MotionSensor] Clearing active message") if $self->debuglevel(1, 'insteon'); } $clear_message = 1; $$self{_ext_set_get_action} = undef; @@ -455,7 +455,7 @@ sub _process_message { $self->_process_command_stack(%msg); } else { main::print_log("[Insteon::MotionSensor] WARN: Unknown Extended " - ."Set/Get Data Message Received for ". $self->get_object_name) if $self->debuglevel(); + ."Set/Get Data Message Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); } } else { @@ -817,9 +817,9 @@ sub _process_message { elsif ($msg{command} eq "extended_set_get" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); #If this was a get request don't clear until data packet received - main::print_log("[Insteon::TriggerLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::TriggerLinc] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); if ($$self{_ext_set_get_action} eq 'set'){ - main::print_log("[Insteon::TriggerLinc] Clearing active message") if $self->debuglevel(); + main::print_log("[Insteon::TriggerLinc] Clearing active message") if $self->debuglevel(1, 'insteon'); $clear_message = 1; $$self{_ext_set_get_action} = undef; $self->_process_command_stack(%msg); @@ -837,7 +837,7 @@ sub _process_message { $self->_process_command_stack(%msg); } else { main::print_log("[Insteon::TriggerLinc] WARN: Corrupt Extended " - ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(); + ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); } } else { diff --git a/lib/Insteon/Thermostat.pm b/lib/Insteon/Thermostat.pm index a8f88fb82..e9eea1a35 100755 --- a/lib/Insteon/Thermostat.pm +++ b/lib/Insteon/Thermostat.pm @@ -215,7 +215,7 @@ Sets fan to 'on' or 'auto' sub fan{ my ($self, $state) = @_; $state = lc($state); - main::print_log("[Insteon::Thermostat] Fan $state") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Fan $state") if $self->debuglevel(1, 'insteon'); my $fan; if (($state eq 'on') or ($state eq 'fan_on')) { $fan = '07'; @@ -236,7 +236,7 @@ Sets a new cool setpoint. =cut sub cool_setpoint{ my ($self, $temp) = @_; - main::print_log("[Insteon::Thermostat] Cool setpoint -> $temp") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Cool setpoint -> $temp") if $self->debuglevel(1, 'insteon'); if($temp !~ /^\d+$/){ main::print_log("[Insteon::Thermostat] ERROR: cool_setpoint $temp not numeric"); return; @@ -250,7 +250,7 @@ Sets a new heat setpoint. =cut sub heat_setpoint{ my ($self, $temp) = @_; - main::print_log("[Insteon::Thermostat] Heat setpoint -> $temp") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Heat setpoint -> $temp") if $self->debuglevel(1, 'insteon'); if($temp !~ /^\d+$/){ main::print_log("[Insteon::Thermostat] ERROR: heat_setpoint $temp not numeric"); return; @@ -374,7 +374,7 @@ sub _is_info_request { my $is_info_request = ($cmd eq 'thermostat_get_zone_info') ? 1 : 0; if ($is_info_request) { my $val = $msg{extra}; - main::print_log("[Insteon::Thermostat] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(1, 'insteon'); if ($$self{_zone_action} eq "temp") { $val = (hex $val) / 2; # returned value is twice the real value if (exists $$self{'temp'} and ($$self{'temp'} != $val)) { @@ -420,21 +420,21 @@ sub _process_message elsif ($msg{command} eq "thermostat_setpoint_cool" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermostat] Received ACK of cool setpoint ". - "for ". $self->get_object_name) if $self->debuglevel(); + "for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->_cool_sp((hex($msg{extra})/2)); $clear_message = 1; } elsif ($msg{command} eq "thermostat_setpoint_heat" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermostat] Received ACK of heat setpoint ". - "for ". $self->get_object_name) if $self->debuglevel(); + "for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->_heat_sp((hex($msg{extra})/2)); $clear_message = 1; } elsif ($$self{_zone_action} eq 'setpoint' && $$self{m_pending_setpoint}) { $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); # we got our cool setpoint in auto mode - main::print_log("[Insteon::Thermostat] Processing data for $msg{command} with value: $msg{extra}") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Processing data for $msg{command} with value: $msg{extra}") if $self->debuglevel(1, 'insteon'); my $val = (hex $msg{extra})/2; $self->_cool_sp($val); $$self{m_setpoint_pending} = 0; @@ -498,7 +498,7 @@ Sets system mode to argument: 'off', 'heat', 'cool', 'auto', 'program_heat', sub mode{ my ($self, $state) = @_; $state = lc($state); - main::print_log("[Insteon::Thermostat] Mode $state") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Mode $state") if $self->debuglevel(1, 'insteon'); my $mode; if ($state eq 'off') { $mode = "09"; @@ -527,7 +527,7 @@ sub _is_info_request { my $is_info_request; if ($cmd eq 'thermostat_control' && $$self{_control_action} eq "mode") { my $val = $msg{extra}; - main::print_log("[Insteon::Thermo_i1] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i1] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(1, 'insteon'); if ($val eq '00') { $self->_mode('off'); } elsif ($val eq '01') { @@ -719,16 +719,16 @@ sub _process_message { elsif ($msg{command} eq "extended_set_get" && $msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); #If this was a get request don't clear until data packet received - main::print_log("[Insteon::Thermo_i2CS] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i2CS] Extended Set/Get ACK Received for " . $self->get_object_name) if $self->debuglevel(1, 'insteon'); if ($$self{_ext_set_get_action} eq 'set'){ - main::print_log("[Insteon::Thermo_i2CS] Clearing active message") if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i2CS] Clearing active message") if $self->debuglevel(1, 'insteon'); $clear_message = 1; $$self{_ext_set_get_action} = undef; $self->_process_command_stack(%msg); } elsif ($$self{_ext_set_get_action} eq 'set_high_humid'){ main::print_log("[Insteon::Thermostat] Received ACK of high humid setpoint ". - "for ". $self->get_object_name) if $self->debuglevel(); + "for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->_high_humid_sp($$self{_high_humid_pending}); $clear_message = 1; $$self{_ext_set_get_action} = undef; @@ -737,7 +737,7 @@ sub _process_message { } elsif ($$self{_ext_set_get_action} eq 'set_low_humid'){ main::print_log("[Insteon::Thermostat] Received ACK of low humid setpoint ". - "for ". $self->get_object_name) if $self->debuglevel(); + "for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->_low_humid_sp($$self{_low_humid_pending}); $clear_message = 1; $$self{_ext_set_get_action} = undef; @@ -749,7 +749,7 @@ sub _process_message { if (substr($msg{extra},0,4) eq "0201") { $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Extended Set/Get Data ". - "Received for ". $self->get_object_name) if $self->debuglevel(); + "Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); #0 = 2 #14 = Cool SP #2 = 1 #16 = humidity #3 = day #18 = temp in Celsius High byte @@ -821,37 +821,37 @@ sub _process_message { } else { main::print_log("[Insteon::Thermo_i2CS] WARN: Unknown Extended " - ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(); + ."Set/Get Data Received for ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); } } elsif ($msg{command} eq "status_temp" && !$msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Received Temp Change Message ". - "from ". $self->get_object_name) if $self->debuglevel(); + "from ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->hex_short_temp($msg{extra}); } elsif ($msg{command} eq "status_mode" && !$msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Received Mode Change Message ". - "from ". $self->get_object_name) if $self->debuglevel(); + "from ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->status_mode($msg{extra}); } elsif ($msg{command} eq "status_cool" && !$msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Received Cool Setpoint Change Message ". - "from ". $self->get_object_name) if $self->debuglevel(); + "from ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->hex_cool($msg{extra}); } elsif ($msg{command} eq "status_humid" && !$msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Received Humidity Change Message ". - "from ". $self->get_object_name) if $self->debuglevel(); + "from ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->hex_humid($msg{extra}); } elsif ($msg{command} eq "status_heat" && !$msg{is_ack}){ $self->default_hop_count($msg{maxhops}-$msg{hopsleft}); main::print_log("[Insteon::Thermo_i2CS] Received Heat Setpoint Change Message ". - "from ". $self->get_object_name) if $self->debuglevel(); + "from ". $self->get_object_name) if $self->debuglevel(1, 'insteon'); $self->hex_heat($msg{extra}); } else { @@ -865,7 +865,7 @@ sub _is_info_request { my $is_info_request; if ($cmd eq 'thermostat_control' && $$self{_control_action} eq "mode") { my $val = $msg{extra}; - main::print_log("[Insteon::Thermo_i2CS] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i2CS] Processing is_info_request for $cmd with value: $val") if $self->debuglevel(1, 'insteon'); if ($val eq '09') { $self->_mode('Off'); } elsif ($val eq '04') { @@ -1062,7 +1062,7 @@ Sets system mode to argument: 'off', 'heat', 'cool', 'auto', 'program_heat', sub mode{ my ($self, $state) = @_; $state = lc($state); - main::print_log("[Insteon::Thermostat] Mode $state") if $self->debuglevel(); + main::print_log("[Insteon::Thermostat] Mode $state") if $self->debuglevel(1, 'insteon'); my $mode; if ($state eq 'off') { $mode = "09"; @@ -1110,7 +1110,7 @@ Sets the high humidity setpoint. =cut sub high_humid_setpoint { my ($self, $value) = @_; - main::print_log("[Insteon::Thermo_i2CS] Setting high humid setpoint -> $value") if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i2CS] Setting high humid setpoint -> $value") if $self->debuglevel(1, 'insteon'); if($value !~ /^\d+$/){ main::print_log("[Insteon::Thermo_i2CS] ERROR: Setpoint $value not numeric"); return; @@ -1134,7 +1134,7 @@ Sets the low humidity setpoint. =cut sub low_humid_setpoint { my ($self, $value) = @_; - main::print_log("[Insteon::Thermo_i2CS] Setting low humid setpoint -> $value") if $self->debuglevel(); + main::print_log("[Insteon::Thermo_i2CS] Setting low humid setpoint -> $value") if $self->debuglevel(1, 'insteon'); if($value !~ /^\d+$/){ main::print_log("[Insteon::Thermo_i2CS] ERROR: Setpoint $value not numeric"); return; diff --git a/lib/Insteon_PLM.pm b/lib/Insteon_PLM.pm index 019451663..2b91d37f2 100644 --- a/lib/Insteon_PLM.pm +++ b/lib/Insteon_PLM.pm @@ -218,7 +218,7 @@ sub check_for_data { } else { - &::print_log("[Insteon_PLM] DEBUG2: PLM command timer expired but no transmission in place. Moving on...") if $self->debuglevel(2); + &::print_log("[Insteon_PLM] DEBUG2: PLM command timer expired but no transmission in place. Moving on...") if $self->debuglevel(2, 'insteon'); $self->clear_active_message(); $self->process_queue(); } @@ -388,16 +388,18 @@ sub _send_cmd { # determine the delay from the point that the message was created to # the point that it is queued my $incurred_delay_time = $message->seconds_delayed; - &main::print_log("[Insteon_PLM] DEBUG2: Sending " . $message->to_string . " incurred delay of " - . sprintf('%.2f',$incurred_delay_time) . " seconds; starting hop-count: " - . ((ref $message->setby && $message->setby->isa('Insteon::BaseObject')) ? $message->setby->default_hop_count : "?")) if $self->debuglevel(2); if ($message->isa('Insteon::X10Message')) { # is x10; so, be slow + &main::print_log("[Insteon_PLM] DEBUG2: Sending " . $message->to_string . " incurred delay of " + . sprintf('%.2f',$incurred_delay_time) . " seconds") if $self->debuglevel(2, 'insteon'); $command = $prefix{x10_send} . $command; $delay = $$self{xmit_x10_delay}; # clear command timeout so that we don't wait for an insteon ack before sending the next command } else { my $command_type = $message->command_type; + &main::print_log("[Insteon_PLM] DEBUG2: Sending " . $message->to_string . " incurred delay of " + . sprintf('%.2f',$incurred_delay_time) . " seconds; starting hop-count: " + . ((ref $message->setby && $message->setby->isa('Insteon::BaseObject')) ? $message->setby->default_hop_count : "?")) if $message->setby->debuglevel(2, 'insteon'); $command = $prefix{$command_type} . $command; if ($command_type eq 'all_link_send' or $command_type eq 'insteon_send' or $command_type eq 'insteon_ext_send' or $command_type eq 'all_link_direct_cleanup') { @@ -412,8 +414,10 @@ sub _send_cmd { } else { - &::print_log( "[Insteon_PLM] DEBUG3: Sending PLM raw data: ".lc($command)) if $self->debuglevel(3); - &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($command)) if $self->debuglevel(4); + my $debug_obj = $self; + $debug_obj = $message->setby if ($message->can('setby') && ref $message->setby); + &::print_log( "[Insteon_PLM] DEBUG3: Sending PLM raw data: ".lc($command)) if $debug_obj->debuglevel(3, 'insteon'); + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($command)) if $debug_obj->debuglevel(4, 'insteon'); my $data = pack("H*",$command); $main::Serial_Ports{$instance}{object}->write($data) if $main::Serial_Ports{$instance}; @@ -442,7 +446,7 @@ sub _parse_data { # it is possible that a fragment exists from a previous attempt; so, if it exists, prepend it if ($$self{_data_fragment}) { - &::print_log("[Insteon_PLM] DEBUG3: Prepending prior data fragment: $$self{_data_fragment}") if $self->debuglevel(3); + &::print_log("[Insteon_PLM] DEBUG3: Prepending prior data fragment: $$self{_data_fragment}") if $self->debuglevel(3, 'insteon'); # maintain a copy of the parsed data fragment $$self{_prior_data_fragment} = $$self{_data_fragment}; # append if not a repeat @@ -456,7 +460,7 @@ sub _parse_data { $$self{_prior_data_fragment} = ''; } - &::print_log( "[Insteon_PLM] DEBUG3: Received PLM raw data: $data") if $self->debuglevel(3); + &::print_log( "[Insteon_PLM] DEBUG3: Received PLM raw data: $data") if $self->debuglevel(3, 'insteon'); # begin by pulling out any PLM ack/nacks my $prev_cmd = ''; @@ -492,7 +496,9 @@ sub _parse_data { $entered_ack_loop = 1; if ($parsed_data =~ /^($ackcmd)|($nackcmd)|($prefix{plm_info}\w{12}06)|($prefix{plm_info}\w{12}15)|($prefix{all_link_first_rec}15)|($prefix{all_link_next_rec}15)|($badcmd)$/) { - &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4); + my $debug_obj = $self; + $debug_obj = $self->active_message->setby if ($self->active_message->can('setby') && ref $self->active_message->setby); + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $debug_obj->debuglevel(4, 'insteon'); my $ret_code = substr($parsed_data,length($parsed_data)-2,2); my $record_type = substr($parsed_data,0,4); my $message_data = substr($parsed_data,4,length($parsed_data)-4); @@ -515,7 +521,7 @@ sub _parse_data { package main; eval ($self->active_message->success_callback); &::print_log("[Insteon_PLM] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->active_message->setby->debuglevel(1, 'insteon'); package Insteon_PLM; } # clear the active message because we're done @@ -523,8 +529,10 @@ sub _parse_data { } else { + my $debug_obj = $self; + $debug_obj = $self->active_message->setby if ($self->active_message->can('setby') && ref $self->active_message->setby); &::print_log("[Insteon_PLM] DEBUG3: Received PLM acknowledge: " - . $pending_message->to_string) if $self->debuglevel(3); + . $pending_message->to_string) if $debug_obj->debuglevel(3, 'insteon'); } # X10 messages don't ACK back on the powerline, so clear them if the PLM acknowledges @@ -552,7 +560,7 @@ sub _parse_data { package main; eval ($callback); &::print_log("[Insteon_PLM] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->active_message->setby->debuglevel(1, 'insteon'); package Insteon_PLM; } } @@ -579,7 +587,7 @@ sub _parse_data { $self->_aldb->scandatetime(&main::get_tickcount); &::print_log("[Insteon_PLM] " . $self->get_object_name . " completed link memory scan: status: " . $self->_aldb->health()) - if $self->debuglevel(); + if $self->debuglevel(1, 'insteon'); if ($$self{_mem_callback}) { my $callback = $$self{_mem_callback}; @@ -587,7 +595,7 @@ sub _parse_data { package main; eval ($callback); &::print_log("[Insteon_PLM] WARN1: Error encountered during nack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon_PLM; } } @@ -637,7 +645,7 @@ sub _parse_data { package main; eval ($callback); &::print_log("[Insteon_PLM] WARN1: Error encountered during ack callback: " . $@) - if $@ and $self->debuglevel(1); + if $@ and $self->debuglevel(1, 'insteon'); package Insteon_PLM; } # clear the active message because we're done @@ -665,7 +673,6 @@ sub _parse_data { # is $parsed_data an accidental anomoly? (there are other cases; but, this is a good start) if ($parsed_data =~ /^($prefix{insteon_send}\w{12}06)|($prefix{insteon_send}\w{12}15)$/) { - &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4); # first, parse the content to confirm that it could be a legitimate ACK my $unknown_deviceid = substr($parsed_data,4,6); my $unknown_msg_flags = substr($parsed_data,10,2); @@ -674,6 +681,7 @@ sub _parse_data { my $unknown_obj = &Insteon::get_object($unknown_deviceid, '01'); if ($unknown_obj) { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $unknown_obj->debuglevel(4, 'insteon'); &::print_log("[Insteon_PLM] WARN: encountered '$parsed_data' " . "from " . $unknown_obj->get_object_name() . " with command: $unknown_command, but expected '$ackcmd'."); @@ -681,6 +689,7 @@ sub _parse_data { } else { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); &::print_log("[Insteon_PLM] ERROR: encountered '$parsed_data' " . "that does not match any known device ID (expected '$ackcmd')." . " Discarding received data."); @@ -710,10 +719,10 @@ sub _parse_data { { #ignore blanks.. the split does odd things next if $parsed_data eq ''; - &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4); + if ($previous_parsed_data eq $parsed_data){ # guard against repeats - ::print_log("[Insteon_PLM] DEBUG3: Dropped duplicate message: $parsed_data") if $self->debuglevel(3); + ::print_log("[Insteon_PLM] DEBUG3: Dropped duplicate message: $parsed_data") if $self->debuglevel(3, 'insteon'); next; } $previous_parsed_data = $parsed_data; # and, now reinitialize @@ -727,26 +736,42 @@ sub _parse_data { if ($parsed_prefix eq $prefix{insteon_received} and ($message_length == 22)) { #Insteon Standard Received + my $find_obj = Insteon::get_object(substr($parsed_data,4,6), '01'); + if (ref $find_obj) { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $find_obj->debuglevel(4, 'insteon'); + } + else { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); + } $self->on_standard_insteon_received($message_data); } elsif ($parsed_prefix eq $prefix{insteon_ext_received} and ($message_length == 50)) { #Insteon Extended Received + my $find_obj = Insteon::get_object(substr($parsed_data,4,6), '01'); + if (ref $find_obj) { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $find_obj->debuglevel(4, 'insteon'); + } + else { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); + } $self->on_extended_insteon_received($message_data); } elsif($parsed_prefix eq $prefix{x10_received} and ($message_length == 8)) { #X10 Received + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); my $x10_message = new Insteon::X10Message($parsed_data); my $x10_data = $x10_message->get_formatted_data(); - &::print_log("[Insteon_PLM] DEBUG3: received x10 data: $x10_data") if $self->debuglevel(3); + &::print_log("[Insteon_PLM] DEBUG3: received x10 data: $x10_data") if $self->debuglevel(3, 'insteon'); &::process_serial_data($x10_data,undef,$self); } elsif ($parsed_prefix eq $prefix{all_link_complete} and ($message_length == 20)) { #ALL-Linking Completed + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); my $link_address = substr($message_data,4,6); - &::print_log("[Insteon_PLM] DEBUG2: ALL-Linking Completed with $link_address ($message_data)") if $self->debuglevel(2); + &::print_log("[Insteon_PLM] DEBUG2: ALL-Linking Completed with $link_address ($message_data)") if $self->debuglevel(2, 'insteon'); if ($self->active_message->success_callback){ main::print_log("[Insteon::Insteon_PLM] DEBUG4: Now calling message success callback: " - . $self->active_message->success_callback) if $self->debuglevel(4); + . $self->active_message->success_callback) if $self->debuglevel(4, 'insteon'); package main; eval $self->active_message->success_callback; ::print_log("[Insteon::Insteon_PLM] problem w/ success callback: $@") if $@; @@ -763,29 +788,32 @@ sub _parse_data { # bytes 0-1 - group; 2-7 device address my $failure_group = substr($message_data,0,2); my $failure_device = substr($message_data,2,6); - - &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure from device: " - . "$failure_device and group: $failure_group") if $self->debuglevel(2); - my $failed_object = &Insteon::get_object($failure_device,'01'); if (ref $failed_object){ + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $failed_object->debuglevel(4, 'insteon'); + &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure from " . $failed_object->get_object_name + . " for all link group: $failure_group. Trying a direct cleanup.") if $failed_object->debuglevel(2, 'insteon'); my $message = new Insteon::InsteonMessage('all_link_direct_cleanup', $failed_object, $self->active_message->command, $failure_group); push(@{$$failed_object{command_stack}}, $message); $failed_object->_process_command_stack(); } else { - &::print_log("[Insteon_PLM] WARN: Device ID: $failure_device does not exist. You may " + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); + &::print_log("[Insteon_PLM] Received all-link cleanup failure from an unkown device id: " + . "$failure_device and for all link group: $failure_group. You may " . "want to run delete orphans to remove this link from your PLM"); } } else { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure." - . " But there is no pending message.") if $self->debuglevel(2); + . " But there is no pending message.") if $self->debuglevel(2, 'insteon'); } } elsif ($parsed_prefix eq $prefix{all_link_record} and ($message_length == 20)) { #ALL-Link Record Response - &::print_log("[Insteon_PLM] DEBUG2: ALL-Link Record Response:$message_data") if $self->debuglevel(2); + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); + &::print_log("[Insteon_PLM] DEBUG2: ALL-Link Record Response:$message_data") if $self->debuglevel(2, 'insteon'); $self->_aldb->parse_alllink($message_data); # before doing the next, make sure that the pending command # (if it sitll exists) is pulled from the queue @@ -795,16 +823,18 @@ sub _parse_data { } elsif ($parsed_prefix eq $prefix{plm_user_reset} and ($message_length == 4)) { + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); main::print_log("[Insteon_PLM] Detected PLM user reset to factory defaults"); } elsif ($parsed_prefix eq $prefix{all_link_clean_status} and ($message_length == 6)) { #ALL-Link Cleanup Status Report + &::print_log( "[Insteon_PLM] DEBUG4:\n".Insteon::MessageDecoder::plm_decode($parsed_data)) if $self->debuglevel(4, 'insteon'); my $cleanup_ack = substr($message_data,0,2); if ($cleanup_ack eq '15') { &::print_log("[Insteon_PLM] WARN1: All-link cleanup failure for scene: " . $self->active_message->setby->get_object_name . ". Retrying in 1 second.") - if $self->debuglevel(1); + if $self->active_message->setby->debuglevel(1, 'insteon'); $self->retry_active_message(); # except that we should cause a bit of a delay to let things settle out $self->_set_timeout('xmit', 1000); @@ -814,7 +844,7 @@ sub _parse_data { { my $message_to_string = ($self->active_message) ? $self->active_message->to_string() : ""; &::print_log("[Insteon_PLM] Received all-link cleanup success: $message_to_string") - if $self->debuglevel(); + if $self->active_message->setby->debuglevel(1, 'insteon'); if (ref $self->active_message && ref $self->active_message->setby){ my $object = $self->active_message->setby; $object->is_acknowledged(1); @@ -831,14 +861,14 @@ sub _parse_data { if ($self->active_message){ my $nack_delay = ($::config_parms{Insteon_PLM_disable_throttling}) ? 0.3 : 1.0; &::print_log("[Insteon_PLM] DEBUG3: Interface extremely busy. Resending command" - . " after delaying for $nack_delay second") if $self->debuglevel(3); + . " after delaying for $nack_delay second") if $self->debuglevel(3, 'insteon'); $self->_set_timeout('xmit',$nack_delay * 1000); $self->active_message->no_hop_increase(1); $self->retry_active_message(); $process_next_command = 0; } else { &::print_log("[Insteon_PLM] DEBUG3: Interface extremely busy." - . " No message to resend.") if $self->debuglevel(3); + . " No message to resend.") if $self->debuglevel(3, 'insteon'); } $nack_count++; } @@ -847,7 +877,7 @@ sub _parse_data { if ($parsed_data ne ''){ $$self{_data_fragment} .= $parsed_data; ::print_log("[Insteon_PLM] DEBUG3: Saving parsed data fragment: " - . $parsed_data) if( $self->debuglevel(3)); + . $parsed_data) if( $self->debuglevel(3, 'insteon')); } } else @@ -857,7 +887,7 @@ sub _parse_data { unless (($parsed_data eq $$self{_prior_data_fragment}) or ($parsed_data eq $$self{_data_fragment})) { $$self{_data_fragment} .= $parsed_data; main::print_log("[Insteon_PLM] DEBUG3: Saving parsed data fragment: " - . $parsed_data) if( $self->debuglevel(3)); + . $parsed_data) if( $self->debuglevel(3, 'insteon')); } } } @@ -865,7 +895,7 @@ sub _parse_data { unless( $entered_rcv_loop or $$self{_data_fragment}) { $$self{_data_fragment} = $residue_data; main::print_log("[Insteon_PLM] DEBUG3: Saving residue data fragment: " - . $residue_data) if( $residue_data and $self->debuglevel(3)); + . $residue_data) if( $residue_data and $self->debuglevel(3, 'insteon')); } if ($process_next_command) {