From 6d8f121f3ae27faac63c697be83219ecb28e02b2 Mon Sep 17 00:00:00 2001 From: H Plato Date: Sun, 31 May 2015 11:44:18 -0600 Subject: [PATCH 1/3] Some cosmetic changes to logging data --- lib/Venstar_Colortouch.pm | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/Venstar_Colortouch.pm b/lib/Venstar_Colortouch.pm index cb19ea1bf..d4f5fa845 100644 --- a/lib/Venstar_Colortouch.pm +++ b/lib/Venstar_Colortouch.pm @@ -201,7 +201,7 @@ sub _get_JSON_data { main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Warning, failed to get data. Response code $responseCode"); if (defined $self->{child_object}->{comm}) { if ($self->{child_object}->{comm}->state() ne "offline") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); + main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating to offline..." if ($self->{loglevel}); $self->{child_object}->{comm}->set("offline",'poll'); } } @@ -209,7 +209,7 @@ sub _get_JSON_data { } else { if (defined $self->{child_object}->{comm}) { if ($self->{child_object}->{comm}->state() ne "online") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); + main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating to online..." if ($self->{loglevel}); $self->{child_object}->{comm}->set("online",'poll'); } } @@ -234,6 +234,28 @@ sub _get_JSON_data { sub _push_JSON_data { my ($self, $type, $params) = @_; + my (@fan,@fanstate,@modename,@statename,@schedule,@home); + $fan[0] = "auto"; + $fan[1] = "on"; + $fanstate[0] = "off"; + $fanstate[1] = "running"; + $home[0] = "home"; + $home[1] = "away"; + $modename[0] = "off"; + $modename[1] = "heating"; + $modename[2] = "cooling"; + $modename[3] = "auto"; + $statename[0] = "idle"; + $statename[1] = "heating"; + $statename[2] = "cooling"; + $statename[3] = "lockout"; + $statename[4] = "error"; + $schedule[0] = "morning (occupied1)"; + $schedule[1] = "day (occupied2)"; + $schedule[2] = "evening (occupied3)"; + $schedule[3] = "night (occupied4)"; + $schedule[255] = "inactive"; + my $cmd; #print "VCT DB: $params\n"; $self->stop_timer; #stop timer to prevent a clash of updates @@ -268,14 +290,14 @@ sub _push_JSON_data { } if ($caway ne $away) { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing Away from $caway to $away"); + main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing Away from $home[$caway] to $home[$away]"); $newaway = $away; } else { $newaway = $caway; } if ($csched ne $sched) { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing Schedule from $csched to $sched"); + main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing Schedule from $schedule[$csched] to $schedule[$sched]"); $newsched = $sched; } else { $newsched = $csched; @@ -296,7 +318,7 @@ sub _push_JSON_data { } $cmd = "tempunits=$newunits&away=$newaway&schedule=$newsched&hum_setpoint=$newhumsp&dehum_setpoint=$newdehumsp"; - main::print_log("Sending Settings command $cmd to " . $self->{host});# if $self->{debug}; + main::print_log("Sending Settings command $cmd to " . $self->{host}) if $self->{debug}; } elsif ($type eq 'control') { #mode=0&fan=0&heattemp=70&cooltemp=75 @@ -316,18 +338,18 @@ sub _push_JSON_data { $heattemp = $cheattemp if (!$heattemp); $cooltemp = $ccooltemp if (!$cooltemp); - main::print_log("data1=$isSuccessResponse,$cmode,$cfan,$cheattemp,$ccooltemp,$setpointdelta"); #TODO pass object to get debug - main::print_log("data2=$mode,$fan,$heattemp,$cooltemp"); #TODO debug + main::print_log("data1=$isSuccessResponse,$cmode,$cfan,$cheattemp,$ccooltemp,$setpointdelta") if $self->{debug}; #TODO pass object to get debug + main::print_log("data2=$mode,$fan,$heattemp,$cooltemp") if $self->{debug}; #TODO debug if ($cmode ne $mode) { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing mode from $cmode to $mode"); + main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing mode from $modename[$cmode] to $modename[$mode]"); $newmode = $mode; } else { $newmode = $cmode; } if ($cfan ne $fan) { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing fan from $cfan to $fan"); + main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Changing fan from $fanstate[$cfan] to $fanstate[$fan]"); $newfan = $fan; } else { $newfan = $cfan; From 5cd0ba467b33208e12d59f20c5bea46cc9aec529 Mon Sep 17 00:00:00 2001 From: H Plato Date: Sat, 11 Jul 2015 12:24:09 -0600 Subject: [PATCH 2/3] Fixes to the communication tracker object --- lib/Venstar_Colortouch.pm | 53 +++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/lib/Venstar_Colortouch.pm b/lib/Venstar_Colortouch.pm index d4f5fa845..f5147b74e 100644 --- a/lib/Venstar_Colortouch.pm +++ b/lib/Venstar_Colortouch.pm @@ -71,6 +71,7 @@ sub new { $self->{host} = $host; $self->{debug} = 0; $self->{loglevel} = 1; + $self->{status} = ""; $self->{timeout} = 15; #300; $self->_init; @@ -154,23 +155,23 @@ sub poll { $self->{data}->{sensors} = $sensors; $self->{data}->{timestamp} = time; $self->{data}->{retry} = 0; - if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "online") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); - $self->{child_object}->{comm}->set("online",'poll'); - } - } + #if (defined $self->{child_object}->{comm}) { + # if ($self->{child_object}->{comm}->state() ne "online") { + # main::print_log "[Venstar Colortouch:". $self->{data}->{name} . "]] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to online..." if ($self->{loglevel}); + # $self->{child_object}->{comm}->set("online",'poll'); + # } + #} return ('1'); - } else { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Problem retrieving poll data from " . $self->{host}); - $self->{data}->{retry}++; - if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "offline") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); - $self->{child_object}->{comm}->set("offline",'poll'); - } - } - return ('0'); + #} else { + # main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Problem retrieving poll data from " . $self->{host}); + # $self->{data}->{retry}++; + # if (defined $self->{child_object}->{comm}) { + # if ($self->{child_object}->{comm}->state() ne "offline") { + # main::print_log "[Venstar Colortouch:". $self->{data}->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to offline..." if ($self->{loglevel}); + # $self->{child_object}->{comm}->set("offline",'poll'); + # } + # } + # return ('0'); } } @@ -200,16 +201,18 @@ sub _get_JSON_data { if (! $isSuccessResponse ) { main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Warning, failed to get data. Response code $responseCode"); if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "offline") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating to offline..." if ($self->{loglevel}); + if ($self->{status} eq "online") { + main::print_log "[Venstar Colortouch:". $self->{data}->{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'); } } return ('0'); } else { if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "online") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating to online..." if ($self->{loglevel}); + if ($self->{status} eq "offline") { + main::print_log "[Venstar Colortouch:". $self->{data}->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to online..." if ($self->{loglevel}); + $self->{status} = "online"; $self->{child_object}->{comm}->set("online",'poll'); } } @@ -413,15 +416,17 @@ sub _push_JSON_data { if (! $isSuccessResponse ) { main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Warning, failed to push data. Response code $responseCode"); if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "offline") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); + if ($self->{status} eq "online") { + main::print_log "[Venstar Colortouch:". $self->{data}->{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'); } } } else { if (defined $self->{child_object}->{comm}) { - if ($self->{child_object}->{comm}->state() ne "online") { - main::print_log "[Venstar Colortouch] Communication Tracking object found. Updating..." if ($self->{loglevel}); + if ($self->{status} eq "offline") { + main::print_log "[Venstar Colortouch:". $self->{data}->{name} . "] Communication Tracking object found. Updating from " . $self->{child_object}->{comm}->state() . " to online..." if ($self->{loglevel}); + $self->{status} = "online"; $self->{child_object}->{comm}->set("online",'poll'); } } From 0c3a8960e98ba19c205d9ace3e265215d4e785b1 Mon Sep 17 00:00:00 2001 From: H Plato Date: Sun, 3 Jan 2016 09:59:55 -0700 Subject: [PATCH 3/3] Fixed a typo when setting setpoints --- lib/Venstar_Colortouch.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Venstar_Colortouch.pm b/lib/Venstar_Colortouch.pm index f5147b74e..a2c9cb9d0 100644 --- a/lib/Venstar_Colortouch.pm +++ b/lib/Venstar_Colortouch.pm @@ -382,8 +382,8 @@ sub _push_JSON_data { $newheatsp=$cheattemp; } - if (($newheatsp - $newcoolsp) < $setpointdelta) { - main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Error: Cooling and Heating setpoints need to be less than setpoint $setpointdelta"); + if (($newheatsp - $newcoolsp) > $setpointdelta) { + main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Error: Cooling ($newcoolsp) and Heating ($newheatsp) setpoints need to be less than setpoint $setpointdelta"); main::print_log("[Venstar Colortouch:". $self->{data}->{name} . "] Not setting setpoints"); $newcoolsp=$ccooltemp; $newheatsp=$cheattemp;