diff --git a/fhem/FHEM/00_THZ.pm b/fhem/FHEM/00_THZ.pm index c08dcca2a..f9f18cd68 100644 --- a/fhem/FHEM/00_THZ.pm +++ b/fhem/FHEM/00_THZ.pm @@ -2,7 +2,7 @@ # 00_THZ # $Id$ # by immi 02/2015 -my $thzversion = "0.139"; +my $thzversion = "0.140"; # this code is based on the hard work of Robert; I just tried to port it # http://robert.penz.name/heat-pump-lwz/ ######################################################################################## @@ -170,6 +170,19 @@ my %parsinghash = ( [" onHysteresisNo: ", 32, 2, "hex", 1], [" offHysteresisNo: ", 34, 2, "hex", 1], [" HCBoosterStage: ", 36, 2, "hex", 1] ], + "F4hc1214" => [["outsideTemp: ", 4, 4, "hex2int", 10], [" x08: ", 8, 4, "hex2int", 10], + [" returnTemp: ", 12, 4, "hex2int", 10], [" integralHeat: ", 16, 4, "hex2int", 1], + [" flowTemp: ", 20, 4, "hex2int", 10], [" heatSetTemp: ", 24, 4, "hex2int", 10], + [" heatTemp: ", 28, 4, "hex2int", 10], + [" seasonMode: ", 38, 2, "somwinmode", 1], #[" x40: ", 40, 4, "hex2int", 1], + [" integralSwitch: ", 44, 4, "hex2int", 1], [" opMode: ", 48, 2, "opmodehc", 1], + #[" x52: ", 52, 4, "hex2int", 1], + [" roomSetTemp: ",62, 4, "hex2int", 10], [" x60: ", 60, 4, "hex2int", 10], + [" x64: ", 64, 4, "hex2int", 10], [" insideTempRC: ", 68, 4, "hex2int", 10], + [" x72: ", 72, 4, "hex2int", 10], [" x76: ", 76, 4, "hex2int", 10], + [" onHysteresisNo: ", 32, 2, "hex", 1], [" offHysteresisNo: ", 34, 2, "hex", 1], + [" HCBoosterStage: ", 36, 2, "hex", 1] + ], "F5hc2" => [["outsideTemp: ", 4, 4, "hex2int", 10], [" returnTemp: ", 8, 4, "hex2int", 10], [" vorlaufTemp: ", 12, 4, "hex2int", 10], [" heatSetTemp: ", 16, 4, "hex2int", 10], [" heatTemp: ", 20, 4, "hex2int", 10], [" stellgroesse: ", 24, 4, "hex2int", 10], @@ -554,7 +567,6 @@ my %getsonly2xx = ( "p01-p12" => {cmd2=>"17", type =>"17pxx206", unit =>""}, "sProgram" => {cmd2=>"EE", type =>"EEprg206", unit =>""}, "sDHW" => {cmd2=>"F3", type =>"F3dhw", unit =>""}, - "sHC1" => {cmd2=>"F4", type =>"F4hc1", unit =>""}, "sHC2" => {cmd2=>"F5", type =>"F5hc2", unit =>""}, "sSystem" => {cmd2=>"F6", type =>"F6sys206", unit =>""}, "sHistory" => {cmd2=>"09", type =>"09his206", unit =>""}, @@ -563,13 +575,16 @@ my %getsonly2xx = ( "sTimedate" => {cmd2=>"FC", type =>"FCtime206", unit =>""}, ); my %getsonly206 = ( - "pFan" => {cmd2=>"01", type =>"01pxx206", unit =>""}, + "sHC1" => {cmd2=>"F4", type =>"F4hc1", unit =>""}, + "pFan" => {cmd2=>"01", type =>"01pxx206", unit =>""}, "sLast10errors" => {cmd2=>"D1", type =>"D1last206", unit =>""}, "sFirmware" => {cmd2=>"FD", type =>"FDfirm", unit =>""}, "sFirmware-Id" => {cmd2=>"FE", type =>"FEfirmId", unit =>""}, ); my %getsonly214 = ( "pFan" => {cmd2=>"01", type =>"01pxx214", unit =>""}, + "sHC1" => {cmd2=>"F4", type =>"F4hc1214", unit =>""}, + ); @@ -1012,12 +1027,11 @@ sub THZ_Get_Comunication($$) { if (!(($hash->{STATE}) eq "opened")) { return("closed connection", "");} #slow down for old firmwares - select(undef, undef, undef, 0.25) if ((AttrVal($hash->{NAME}, "firmware" , "new") eq "2.06") or (AttrVal($hash->{NAME}, "firmware" , "new") eq "2.14")); - + select(undef, undef, undef, 0.25) if (AttrVal($hash->{NAME}, "firmware" , "4.39") =~ /^2/ ); + select(undef, undef, undef, 0.001); THZ_Write($hash, "02"); # step1 --> STX start of text ($err, $msg) = THZ_ReadAnswer($hash); #Expectedanswer1 is "10" DLE data link escape - if ($msg eq "10") { THZ_Write($hash, $cmdHex); # step2 --> send request SOH start of heading -- Null -- ?? -- DLE data link escape -- EOT End of Text ($err, $msg) = THZ_ReadAnswer($hash); @@ -1057,7 +1071,7 @@ sub THZ_ReadAnswer($) Log3 $hash->{NAME}, 5, "$hash->{NAME} start Funktion THZ_ReadAnswer"; ###------Windows support select(undef, undef, undef, 0.025) if( $^O =~ /Win/ ); ###delay of 25 ms for windows-OS, because SimpleReadWithTimeout does not wait - my $buf = DevIo_SimpleReadWithTimeout($hash, 0.5); + my $buf = DevIo_SimpleReadWithTimeout($hash, 0.5); if(!defined($buf)) { Log3 $hash->{NAME}, 3, "$hash->{NAME} THZ_ReadAnswer got no answer from DevIo_SimpleRead. Maybe too slow?"; return ("InterfaceNotRespondig", ""); @@ -1066,7 +1080,6 @@ sub THZ_ReadAnswer($) my $data = uc(unpack('H*', $buf)); my $count =1; my $countmax = 80; - #$countmax = 80 if (AttrVal($hash->{NAME}, "firmware" , "new") eq "2.06"); while (( (length($data) == 1) or (($data =~ m/^01/) and ($data !~ m/1003$/m ))) and ($count <= $countmax)) { ###------Windows support select(undef, undef, undef, 0.005) if( $^O =~ /Win/ ); ###delay of 5 ms for windows-OS, because SimpleReadWithTimeout does not wait @@ -1315,7 +1328,7 @@ sub THZ_Parse1($$) { my $length = length($message); Log3 $hash->{NAME}, 5, "Message length: $length"; my $parsingcmd = substr($message,2,2); - $parsingcmd = substr($message,2,6) if (($parsingcmd =~ m/(0A|0B|0C)/) and (AttrVal($hash->{NAME}, "firmware" , "4.39") ne "2.06") and (AttrVal($hash->{NAME}, "firmware" , "4.39") ne "2.14")); + $parsingcmd = substr($message,2,6) if (($parsingcmd =~ m/(0A|0B|0C)/) and (AttrVal($hash->{NAME}, "firmware" , "4.39") !~ /^2/) ); my $msgtype; my $parsingrule; my $parsingelement; @@ -1453,7 +1466,7 @@ sub THZ_Attr(@) { my ($cmd, $name, $attrName, $attrVal) = @_; my $hash = $defs{$name}; - + $attrVal = "4.39" if ($cmd eq "del"); if ( $attrName eq "firmware" ) { if ($attrVal eq "2.06") { @@ -1474,8 +1487,7 @@ sub THZ_Attr(@) { %gets=(%getsonly539, %sets); THZ_Refresh_all_gets($hash); } - #-- - if (($attrVal eq "4.39") or ($cmd eq "del") or (($attrVal ne "5.39") and ($attrVal ne "2.06") and ($attrVal ne "2.14"))) { + else { #in all other cases I assume $attrVal eq "4.39" cambiato nella v0140 THZ_RemoveInternalTimer("THZ_GetRefresh"); %sets=%sets439; %gets=(%getsonly439, %sets); @@ -1483,10 +1495,6 @@ sub THZ_Attr(@) { } } - - - - if( $attrName =~ /^interval_/ ) { #DevIo_CloseDev($hash); THZ_RemoveInternalTimer("THZ_GetRefresh"); @@ -1546,8 +1554,8 @@ sub function_heatSetTemp($$) { last if(($defs{$_}{TYPE}) =~ "THZ"); } - if (AttrVal($devname, "firmware" , "4.39") =~ "2.") { - ($p13GradientHC1, $p14LowEndHC1, $p15RoomInfluenceHC1) = (split ' ',ReadingsVal($devname,"pHeat1",0))[1,2,3]; + if (AttrVal($devname, "firmware" , "4.39") =~ /^2/ ) { + ($p13GradientHC1, $p14LowEndHC1, $p15RoomInfluenceHC1) = (split ' ',ReadingsVal($devname,"pHeat1",0))[1,3,5]; } else { $p13GradientHC1 = ReadingsVal($devname,"p13GradientHC1",0.4); @@ -1564,10 +1572,11 @@ sub function_heatSetTemp($$) { my $b= -14 * $p13GradientHC1 / $roomSetTemp; my $c= -1 * $p13GradientHC1 /75; my $Simul_heatSetTemp; my $Simul_heatSetTemp_simplified; my @ret; - foreach my $i ($start..$stop) { - $Simul_heatSetTemp = sprintf("%.1f", ($i * $i * $c + $i * $b + $a)); - $Simul_heatSetTemp_simplified = sprintf("%.1f", ($i * $i * $c + $i * $b + $a1)); - push(@ret, [$i, $Simul_heatSetTemp, $Simul_heatSetTemp_simplified]); + foreach ($start..$stop) { + my $tmp =$_ * $_ * $c + $_ * $b; + $Simul_heatSetTemp = sprintf("%.1f", ( $tmp + $a)); + $Simul_heatSetTemp_simplified = sprintf("%.1f", ($tmp + $a1)); + push(@ret, [$_, $Simul_heatSetTemp, $Simul_heatSetTemp_simplified]); } my $titlestring = 'roomSetTemp=' . $roomSetTemp . '°C p13GradientHC1=' . $p13GradientHC1 . ' p14LowEndHC1=' . $p14LowEndHC1 . 'K p15RoomInfluenceHC1=' . $p15RoomInfluenceHC1 . "% insideTemp=" . $insideTemp .'°C' ; return (\@ret, $titlestring, $heatSetTemp, $outside_tempFiltered); @@ -1583,12 +1592,13 @@ sub function_heatSetTemp($$) { sub THZ_PrintcurveSVG { my ($ycurvevalues, $titlestring, $heatSetTemp, $outside_tempFiltered) = function_heatSetTemp(-15,20); +my $v0min= 15; +$v0min= 10 if ((($ycurvevalues->[33][1]) < $v0min ) or (($ycurvevalues->[33][2]) < $v0min)); #lower offset, if out of scale my $vstep= 5; -$vstep= 10 if ((($ycurvevalues->[0][1])>36) or (($ycurvevalues->[0][2])>36)); #change scale if out of scale -my$v0min= 15; +$vstep= 10 if ((($ycurvevalues->[0][1])>($v0min+4*$vstep)) or (($ycurvevalues->[0][2])>($v0min+4*$vstep))); #increase step, if out of scale my $v1=$v0min+$vstep; my $v2=$v1+$vstep; my $v3=$v2+$vstep; my $v4=$v3+$vstep; my $ret = <<'END'; - +