From 95e89146813774c26fae992b4898d77bef460d49 Mon Sep 17 00:00:00 2001 From: Skjall <> Date: Sun, 7 May 2017 17:27:32 +0000 Subject: [PATCH] Vallox: Changed way readings are updated. Added efficiency calculation and readings for HRC. git-svn-id: https://svn.fhem.de/fhem/trunk@14210 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 + fhem/FHEM/36_Vallox.pm | 87 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 5dfd5f939..31d2e894c 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 36_Vallox: Changed way readings are updated. + Added efficiency calculation and readings for HRC. - change: 71_YAMAHA_AVR: changing values of reading values conform to FHEM AV guidelines ("stopped", "playing" or "paused") - bugfix 73_km200.pm: Errorlist unsorted timestamp part 3 diff --git a/fhem/FHEM/36_Vallox.pm b/fhem/FHEM/36_Vallox.pm index 14875c992..733f67de2 100644 --- a/fhem/FHEM/36_Vallox.pm +++ b/fhem/FHEM/36_Vallox.pm @@ -5,6 +5,7 @@ # # @Author Skjall # @Created 21.07.2016 10:18:23 +# @Version 1.2.0 # # The modul reads and writes parameters via RS485 from and to a Vallox # ventilation bus. @@ -845,11 +846,87 @@ sub Vallox_Read($) if($Vallox_datatypes{$rawReadingType}) { if ($singlereading == 1) { - if (ReadingsVal($name,$Vallox_datatypes{$rawReadingType},"unknown") ne $fineReadingValue) { - Log3 ($name, 5, "Vallox: Update Reading: $fineReadingValue"); - readingsSingleUpdate($hash,$Vallox_datatypes{$rawReadingType}, $fineReadingValue, 1) ; - } else { - Log3 ($name, 5, "Vallox: Reading not changed: $fineReadingValue - Doing nothing."); + Log3 ($name, 5, "Vallox: Update Reading: $fineReadingValue"); + + readingsSingleUpdate($hash,$Vallox_datatypes{$rawReadingType}, $fineReadingValue, 1); + + # Efficiency Calculation + #Is this Reading a Temp? + if (substr($Vallox_datatypes{$rawReadingType},0,4) eq "Temp") { + + # If HRC is in Bypass - Efficiency is 0 + if (ReadingsVal($name,"DamperMotorPosition",0) == 1) { + readingsSingleUpdate($hash,"EfficiencyIn", 0, 1); + readingsSingleUpdate($hash,"EfficiencyOut", 0, 1); + readingsSingleUpdate($hash,"EfficiencyAverage", 0, 1); + Log3 ($name, 5, "Vallox: Efficiency Override: HRC Bypass"); + + } else { + + my ($EfficiencyIn,$EfficiencyOut,$TempIncoming,$TempOutside,$TempInside,$TempExhaust) = 0; + + # Efficiency on Keep Temp Inside + # Do we have all nessecary Readings? + if (ReadingsVal($name,"TempIncoming","unknown") ne "unknown" && + ReadingsVal($name,"TempOutside","unknown") ne "unknown" && + ReadingsVal($name,"TempInside","unknown") ne "unknown") { + + + $TempIncoming = ReadingsVal($name,"TempIncoming",-100); + $TempOutside = ReadingsVal($name,"TempOutside",-100); + $TempInside = ReadingsVal($name,"TempInside",-100); + + + # Prevent DIV/0 (if Inside=Outside the HRC does nothing = 100% Efficient) + if ($TempInside-$TempOutside != 0) { + $EfficiencyIn = ($TempIncoming-$TempOutside)/($TempInside-$TempOutside)*100; + + $EfficiencyIn = 100 if ($EfficiencyIn > 100); + + Log3 ($name, 5, "Vallox: Efficiency Inside: (".$TempIncoming."-".$TempIncoming.")/(".$TempInside."-".$TempOutside.")*100 = ".$EfficiencyIn); + readingsSingleUpdate($hash,"EfficiencyIn", $EfficiencyIn, 1); + } else { + Log3 ($name, 5, "Vallox: Efficiency Inside (DIV/0 Prevention): (".$TempIncoming."-".$TempIncoming.")/(".$TempInside."-".$TempOutside.")*100 = 100"); + readingsSingleUpdate($hash,"EfficiencyIn", 100, 1); + } + } + + # Efficiency on Keep Temp Outside + # Do we have all nessecary Readings? + if (ReadingsVal($name,"TempOutside","unknown") ne "unknown" && + ReadingsVal($name,"TempIncoming","unknown") ne "unknown" && + ReadingsVal($name,"TempExhaust","unknown") ne "unknown") { + + $TempOutside = ReadingsVal($name,"TempOutside",-100); + $TempIncoming = ReadingsVal($name,"TempIncoming",-100); + $TempExhaust = ReadingsVal($name,"TempExhaust",-100); + + # Prevent DIV/0 (if Inside=Outside the HRC does nothing = 100% Efficient) + if ($TempOutside-$TempIncoming != 0) { + $EfficiencyOut = ($TempExhaust-$TempIncoming)/($TempOutside-$TempIncoming)*100; + $EfficiencyOut = 100 if ($EfficiencyOut > 100); + Log3 ($name, 5, "Vallox: Efficiency Outside: (".$TempExhaust."-".$TempIncoming.")/(".$TempOutside."-".$TempIncoming.")*100 = ".$EfficiencyOut); + readingsSingleUpdate($hash,"EfficiencyOut", $EfficiencyOut, 1); + } else { + Log3 ($name, 5, "Vallox: Efficiency Outside (DIV/0 Protection): (".$TempExhaust."-".$TempIncoming.")/(".$TempOutside."-".$TempIncoming.")*100 = 100"); + readingsSingleUpdate($hash,"EfficiencyOut", 100, 1); + } + } + + # Average Efficiency + if (ReadingsVal($name,"EfficiencyIn","unknown") ne "unknown" && + ReadingsVal($name,"EfficiencyOut","unknown") ne "unknown") { + $EfficiencyIn = ReadingsVal($name,"EfficiencyIn",-100); + $EfficiencyOut = ReadingsVal($name,"EfficiencyOut",-100); + + my $EfficiencyAverage = ($EfficiencyIn+$EfficiencyOut) / 2; + Log3 ($name, 5, "Vallox: Efficiency Average: (".$EfficiencyIn."+".$EfficiencyOut.")/2 = ".$EfficiencyAverage); + + readingsSingleUpdate($hash,"EfficiencyAverage", $EfficiencyAverage, 1); + } else { + Log3 ($name, 5, "Vallox: Efficiency Average unknown: (".ReadingsVal($name,"EfficiencyIn","unknown")."+".ReadingsVal($name,"EfficiencyOut","unknown").")/2"); + } + } } }