From d01f286730bde27d0027f0d9d43e9b7b034102cd Mon Sep 17 00:00:00 2001 From: mgehre Date: Sun, 9 Dec 2012 14:59:02 +0000 Subject: [PATCH] CUL_MAX: parse Ack payload git-svn-id: https://svn.fhem.de/fhem/trunk@2288 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_MAX.pm | 14 +++++++++++++- fhem/FHEM/14_CUL_MAX.pm | 3 +-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/10_MAX.pm b/fhem/FHEM/10_MAX.pm index df0d9d6ca..75f1b314e 100755 --- a/fhem/FHEM/10_MAX.pm +++ b/fhem/FHEM/10_MAX.pm @@ -328,7 +328,7 @@ MAX_Parse($$) my $batterylow = vec($bits2, 7, 1); #1 if battery is low my $untilStr = defined($until3) ? MAX_ParseDateTime($until1,$until2,$until3)->{str} : ""; - my $measuredTemperature = $until2/10; + my $measuredTemperature = defined($until2) ? $until2/10 : ""; #If the control mode is not "temporary", the cube sends the current (measured) temperature $measuredTemperature = "" if($mode == 2 || $measuredTemperature == 0); $untilStr = "" if($mode != 2); @@ -416,6 +416,18 @@ MAX_Parse($$) $shash->{ERROR} = join(",",$args[0]); } + } elsif($msgtype eq "Ack") { + #The payload of an Ack is a 2-digit hex number (I just saw it being "01") + #with unknown meaning plus the data of a State broadcast from the same device + #For HeatingThermostats, it does not contain the last three "until" bytes (or measured temperature) + if($shash->{type} ~~ ["HeatingThermostat", "WallMountedThermostat"] ) { + return MAX_Parse($hash, "MAX,ThermostatState,$addr,". substr($args[0],2)); + } elsif($shash->{type} eq "ShutterContact") { + return MAX_Parse($hash, "MAX,ShutterContactState,$addr,". substr($args[0],2)); + } else { + Log 2, "MAX_Parse: Don't know how to interpret Ack payload for $shash->{type}"; + } + } else { Log 1, "MAX_Parse: Unknown message $msgtype"; } diff --git a/fhem/FHEM/14_CUL_MAX.pm b/fhem/FHEM/14_CUL_MAX.pm index 2779e7bac..b1f61c8a5 100644 --- a/fhem/FHEM/14_CUL_MAX.pm +++ b/fhem/FHEM/14_CUL_MAX.pm @@ -167,6 +167,7 @@ CUL_MAX_Parse($$) Log 5, "CUL_MAX_Parse: len $len, msgcnt $msgcnt, msgflag $msgFlag, msgTypeRaw $msgType, src $src, dst $dst, groupid $groupid, payload $payload"; if(exists($msgTypes{$msgTypeRaw})) { if($msgType eq "Ack") { + Dispatch($shash, "MAX,Ack,$src,$payload", {RAWMSG => $rmsg}); my $i = 0; while ($i < @waitForAck) { my $packet = $waitForAck[$i]; @@ -178,8 +179,6 @@ CUL_MAX_Parse($$) $i++; } } - #TODO: The Ack payload for HeatingThermostats is 01HHHHHH where HHHHHH are the first 3 bytes of the HeatingThermostatState payload - Log 5, "Got Ack (but no match)"; } elsif($msgType eq "TimeInformation") { if($len == 10) {