diff --git a/fhem/FHEM/00_MAXLAN.pm b/fhem/FHEM/00_MAXLAN.pm index 14ca97efd..2d18024ef 100755 --- a/fhem/FHEM/00_MAXLAN.pm +++ b/fhem/FHEM/00_MAXLAN.pm @@ -539,7 +539,16 @@ MAXLAN_Parse($$) $len = $len+1; #The len field itself was not counted - Dispatch($hash, "MAX,1,define,$addr,$device_types{$devicetype},$serial,$groupid,1", {}) if($device_types{$devicetype} ne "Cube"); + Dispatch($hash, "MAX,1,define,$addr,$device_types{$devicetype},$serial,$groupid", {}) if($device_types{$devicetype} ne "Cube"); + + #Set firmware and testresult on device + my $dhash = $modules{MAX}{defptr}{$addr}; + if(defined($dhash)) { + readingsBeginUpdate($dhash); + readingsBulkUpdate($dhash, "firmware", $firmware); + readingsBulkUpdate($dhash, "testresult", $testresult); + readingsEndUpdate($dhash, 1); + } if($len != length($bindata)) { Dispatch($hash, "MAX,1,Error,$addr,Parts of configuration are missing", {}); @@ -555,7 +564,6 @@ MAXLAN_Parse($$) my ($comforttemp,$ecotemp,$maxsetpointtemp,$minsetpointtemp,$tempoffset,$windowopentemp,$windowopendur,$boost,$decalcifiction,$maxvalvesetting,$valveoffset,$weekprofile) = unpack("CCCCCCCCCCCH364",substr($bindata,18)); my $boostValve = ($boost & 0x1F) * 5; my $boostDuration = $boost >> 5; - #There is some trailing data missing, which maps to the weekly program $comforttemp = MAXLAN_ExtractTemperature($comforttemp); #convert to degree celcius $ecotemp = MAXLAN_ExtractTemperature($ecotemp); #convert to degree celcius $tempoffset = $tempoffset/2.0-3.5; #convert to degree @@ -661,7 +669,7 @@ MAXLAN_Parse($$) } my ($type, $addr, $serial) = unpack("CH6a[10]", decode_base64($args[0])); Log 2, "MAXLAN_Parse: Paired new device, type $device_types{$type}, addr $addr, serial $serial"; - Dispatch($hash, "MAX,1,define,$addr,$device_types{$type},$serial,0,1", {}); + Dispatch($hash, "MAX,1,define,$addr,$device_types{$type},$serial,0", {}); #After a device has been paired, it automatically appears in the "L" and "C" commands, MAXLAN_RequestConfiguration($hash,$addr); diff --git a/fhem/FHEM/14_CUL_MAX.pm b/fhem/FHEM/14_CUL_MAX.pm index ad23f58dc..938ab161e 100644 --- a/fhem/FHEM/14_CUL_MAX.pm +++ b/fhem/FHEM/14_CUL_MAX.pm @@ -308,8 +308,9 @@ CUL_MAX_Parse($$) Log $ll5, "CUL_MAX_Parse: Got TimeInformation: (in GMT) year $year, mon $month, day $day, hour $hour, min $min, sec $sec, unk ($unk1, $unk2, $unk3)"; } } elsif($msgType eq "PairPing") { - my ($unk1,$type,$unk2,$serial) = unpack("CCCa*",pack("H*",$payload)); - Log $ll5, "CUL_MAX_Parse: Got PairPing (dst $dst, pairmode $shash->{pairmode}), unk1 $unk1, type $type, unk2 $unk2, serial $serial"; + my ($firmware,$type,$testresult,$serial) = unpack("CCCa*",pack("H*",$payload)); + #What does testresult mean? + Log $ll5, "CUL_MAX_Parse: Got PairPing (dst $dst, pairmode $shash->{pairmode}), firmware $firmware, type $type, testresult $testresult, serial $serial"; #There are two variants of PairPing: #1. It has a destination address of "000000" and can be paired to any device. @@ -322,11 +323,21 @@ CUL_MAX_Parse($$) #If $isToMe is true, this device is already paired and just wants to be reacknowledged if($shash->{pairmode} || $isToMe) { Log 3, "CUL_MAX_Parse: " . ($isToMe ? "Re-Pairing" : "Pairing") . " device $src of type $device_types{$type} with serial $serial"; - Dispatch($shash, "MAX,$isToMe,define,$src,$device_types{$type},$serial,0,0", {}); + Dispatch($shash, "MAX,$isToMe,define,$src,$device_types{$type},$serial,0", {}); + + #Set firmware and testresult on device + my $dhash = CUL_MAX_DeviceHash($src); + if(defined($dhash)) { + readingsBeginUpdate($dhash); + readingsBulkUpdate($dhash, "firmware", $firmware); + readingsBulkUpdate($dhash, "testresult", $testresult); + readingsEndUpdate($dhash, 1); + } + #Send after dispatch the define, otherwise Send will create an invalid device CUL_MAX_Send($shash, "PairPong", $src, "00"); - return $shash->{NAME} if($isToMe); #Skip default values if just rePairing + return $shash->{NAME} if($isToMe); #if just re-pairing, default values are not restored (I checked) #This are the default values that a device has after factory reset or pairing if($device_types{$type} =~ /HeatingThermostat.*/) {