Skip to content

Commit

Permalink
v1.2.1 - cleaned up some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hplato committed Aug 23, 2018
1 parent e9a6724 commit d9e33e2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/Yeelight.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package Yeelight;

# v1.2
# v1.2.1

#TODO
#- brightness changes change state to on and off
#- test queuing fast commands
#TODO check query data
#- check query data


use strict;
Expand Down Expand Up @@ -167,7 +166,7 @@ sub check_for_socket_data {
$com_status = "offline";
} else {
my $data;
main::print_log( "[Yeelight:" . $self->{name} . "] Data Received [$rec_data]" );
main::print_log( "[Yeelight:" . $self->{name} . "] Data Received [$rec_data]" ) if ( $self->{debug} );

eval { $data = JSON::XS->new->decode($json_data); };

Expand Down Expand Up @@ -196,7 +195,7 @@ sub check_for_socket_data {

if (( defined $self->{child_object}->{comm} ) and ($self->{socket_connected})) {
if ( $self->{status} ne $com_status ) {
main::print_log "[Yeelight:" . $self->{name} . "] A Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
main::print_log "[Yeelight:" . $self->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
$self->{status} = $com_status;
$self->{child_object}->{comm}->set( $com_status, 'poll' );
}
Expand Down Expand Up @@ -300,7 +299,7 @@ sub process_check {

if ( defined $self->{child_object}->{comm} ) {
if ( $self->{status} ne $com_status ) {
main::print_log "[Yeelight:" . $self->{name} . "] 1 Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
main::print_log "[Yeelight:" . $self->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
$self->{status} = $com_status;
$self->{child_object}->{comm}->set( $com_status, 'poll' );
}
Expand Down Expand Up @@ -369,9 +368,11 @@ sub process_check {

if ( defined $self->{child_object}->{comm} ) {
if ( $self->{status} ne $com_status ) {
main::print_log "[Yeelight:" . $self->{name} . "] 2 Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
$self->{status} = $com_status;
$self->{child_object}->{comm}->set( $com_status, 'poll' );
if ($self->{child_object}->{comm}->state() ne $com_status) {
main::print_log "[Yeelight:" . $self->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to " . $com_status . "..." if ( $self->{loglevel} );
$self->{child_object}->{comm}->set( $com_status, 'poll' );
}
}
}
}
Expand Down Expand Up @@ -426,7 +427,7 @@ sub _push_TCP_data {
main::print_log( "[Yeelight:" . $self->{name} . "] WARNING. Queue has grown past " . $self->{max_cmd_queue} . ". Command discarded." );
if ( defined $self->{child_object}->{comm} ) {
if ( $self->{status} ne "offline" ) {
main::print_log "[Yeelight:" . $self->{name} . "] 3 Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to offline..." if ( $self->{loglevel} );
main::print_log "[Yeelight:" . $self->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to offline..." if ( $self->{loglevel} );
$self->{status} = "offline";
$self->{child_object}->{comm}->set( "offline", 'poll' );
}
Expand Down Expand Up @@ -963,3 +964,5 @@ sub set {
# Version History
# v1.0.0 - initial module
# v1.0.1 - color support
# v1.2 - RGB changes
# v1.2.1 - minor fixes

0 comments on commit d9e33e2

Please sign in to comment.