From a7561a0fb59825bafaaed6233bea318a0a633da3 Mon Sep 17 00:00:00 2001 From: Ralf9 <> Date: Fri, 12 Apr 2024 17:56:00 +0000 Subject: [PATCH] 14_CUL_TCM97001.pm: add NX7674, Kuehl- und Gefrierschrank-Thermometer - when you modify the DEF, the old DEF is now deleted - fix Auriol_IAN - update Attributes commandref git-svn-id: https://svn.fhem.de/fhem/trunk@28787 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 6 + fhem/FHEM/14_CUL_TCM97001.pm | 205 ++++++++++++++++++++++++++++++++--- 2 files changed, 197 insertions(+), 14 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index eb820c91b..44e8269ec 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,11 @@ # 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 + - feature: 14_CUL_TCM97001.pm: NX7674, Kuehl- & Gefrierschrank-Thermometer + (Rosenstein & Söhne), zugefügt + Bei einem modify der DEF wird nun die alte DEF gelöscht + - change: 14_CUL_TCM97001.pm: commandref + - bugfix: 14_CUL_TCM97001.pm: Kanal beim Auriol_IAN + - bugfix: 10_IT: Attribut ITfrequency - feature: 74_AutomowerConnect.pm: use widgetList for stayOutZones and workAreas setter, update commandref, some default values changed regarding design attributes diff --git a/fhem/FHEM/14_CUL_TCM97001.pm b/fhem/FHEM/14_CUL_TCM97001.pm index 5b67fcccc..bc21f113b 100755 --- a/fhem/FHEM/14_CUL_TCM97001.pm +++ b/fhem/FHEM/14_CUL_TCM97001.pm @@ -41,6 +41,7 @@ # 05.04.2022 add Mebus HQ7312 # new attribute disableCreateUndefDevice: this can be used to deactivate the creation of new devices # new attribute disableUnknownEvents: with this, the events can be deactivated for unknown messages +# 15.11.2023 add NX7674: fridge and freezer thermometer ############################################## package main; @@ -78,6 +79,7 @@ my %models = ( "W174" => 'W174', "W044" => 'W044', "W132" => 'W132', + "NX7674" => 'NX7674' ); sub @@ -86,9 +88,9 @@ CUL_TCM97001_Initialize($) my ($hash) = @_; $hash->{Match} = "^s....."; - $hash->{DefFn} = "CUL_TCM97001_Define"; - $hash->{UndefFn} = "CUL_TCM97001_Undef"; - $hash->{ParseFn} = "CUL_TCM97001_Parse"; + $hash->{DefFn} = \&CUL_TCM97001_Define; + $hash->{UndefFn} = \&CUL_TCM97001_Undef; + $hash->{ParseFn} = \&CUL_TCM97001_Parse; $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:1,0 " . "$readingFnAttributes " . "max-deviation-temp:1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50 ". @@ -124,6 +126,7 @@ CUL_TCM97001_Initialize($) "W044.*" => { ATTR => "event-min-interval:.*:300 event-on-change-reading:.*", GPLOT => "temp4hum4:Temp/Hum,", FILTER => "%NAME", autocreateThreshold => "2:180"}, "W132.*" => { ATTR => "event-min-interval:.*:300 event-on-change-reading:.*", GPLOT => "temp4hum4:Temp/Hum,", FILTER => "%NAME", autocreateThreshold => "2:180"}, "Mebus7312.*" => { ATTR => "event-min-interval:.*:300 event-on-change-reading:.*", GPLOT => "temp4hum4:Temp/Hum,", FILTER => "%NAME", autocreateThreshold => "2:180"}, + "NX7674.*" => { ATTR => "event-min-interval:.*:300 event-on-change-reading:.*", GPLOT => "temp4:Temp,", FILTER => "%NAME", autocreateThreshold => "2:180"}, "Unknown_.*" => { autocreateThreshold => "2:10"} }; } @@ -138,6 +141,17 @@ CUL_TCM97001_Define($$) return "wrong syntax: define CUL_TCM97001 " if(int(@a) < 3 || int(@a) > 5); + my $dp = $modules{CUL_TCM97001}{defptr}; + my $old = ($dp && $dp->{$a[2]} ? $dp->{$a[2]}{NAME} : ""); + my $olddef = $hash->{OLDDEF}; + my $op = ($hash->{OLDDEF} ? "modify":"define"); + my $oc = ($hash->{OLDDEF} ? $hash->{CODE} : ""); + if ($olddef) { + Log3 $hash, 2 , "CUL_TCM97001_Define: a2=$a[2], dp=$dp, OLDDEF=" . $olddef . ", code=" . $hash->{CODE} . ", old=$old"; + } + return "Cannot $op as the code $a[2] is already used by $old" if ($old && $oc ne $a[2]); + delete($modules{CUL_TCM97001}{defptr}{$oc}) if($oc); + $hash->{CODE} = $a[2]; $hash->{lastT} = 0; $hash->{lastH} = 0; @@ -344,6 +358,27 @@ sub checkCRC_Type1 { return FALSE; } +sub checkCRC_sduinoID33 { + my $hash = shift; + my $bitData = shift; + my $crc = 0; + + for (my $i=0; $i < 34; $i++) { + if (substr($bitData, $i, 1) == ($crc & 1)) { + $crc >>= 1; + } else { + $crc = ($crc>>1) ^ 12; + } + } + $crc ^= oct("0b" . reverse(substr($bitData, 34, 4))); + if ($crc == oct("0b" . reverse(substr($bitData, 38, 4)))) { + Log3 $hash, 5 , $hash->{NAME} . ": CUL_TCM97001 sduinoID33 checksum ok, calc CRC = ref CRC = $crc"; + return TRUE; + } + Log3 $hash, 5 , $hash->{NAME} . ": CUL_TCM97001 sduinoID3 ERROR, checksum not ok!, calc CRC = $crc, ref CRC = " . oct("0b" . reverse(substr($bitData, 38, 4))); + return FALSE; +} + sub checkRain { my $hash = shift; my $iodev = shift; @@ -821,6 +856,9 @@ CUL_TCM97001_Parse($$) } elsif (length($msg) == 12) { my $bin = undef; + my $hlen = length($msg); + my $blen = $hlen * 4; + my $bitData = unpack("B$blen", pack("H$hlen", $msg)); my $idType1 = hex($a[0] . $a[1]); #my $idType2 = hex($a[1] . $a[2]); #my $idType3 = hex($a[0] . $a[1] . $a[2] . (hex($a[3]) & 0x3)); @@ -856,7 +894,7 @@ CUL_TCM97001_Parse($$) $readedModel = AttrVal($name, "model", "Unknown"); Log3 $iodev, 4, "$iodev: CUL_TCM97001 Parse Name: $name , devicecode: $deviceCode , Model defined: $readedModel"; - if (($readedModel eq "Eurochron" || (hex($a[6]) == 0xF && $readedModel eq "Unknown" && $hash->{TYPE} ne "SIGNALduino") && $syncBit[1] < 5000)) { + if (($readedModel eq "Eurochron" || (hex($a[6]) == 0xF && $readedModel eq "Unknown" && $hash->{TYPE} !~ m/^SIGNALduino/) && $syncBit[1] < 5000)) { # EAS 800 # G is every time 1111 # @@ -1032,9 +1070,9 @@ CUL_TCM97001_Parse($$) my $bitUnreverse = ""; my $x = undef; my $bin3; - my $hlen = length($msg); - my $blen = $hlen * 4; - my $bitData = unpack("B$blen", pack("H$hlen", $msg)); + #my $hlen = length($msg); + #my $blen = $hlen * 4; + #my $bitData = unpack("B$blen", pack("H$hlen", $msg)); foreach $x (@a) { $bin3=sprintf("%024b",hex($x)); @@ -1231,6 +1269,49 @@ CUL_TCM97001_Parse($$) } } + #if (checkCRC_sduinoID33($hash,$bitData) == TRUE && ($readedModel eq "Unknown" || $readedModel eq "NX7674")) { + # https://forum.fhem.de/index.php?topic=135692.0 + # Rosenstein & Soehne, Kuehl- & Gefrierschrank-Thermometer + # + # 0 4 | 8 12 | 16 20 | 24 28 | 32 36 | 40 + # 00Ii iiii | ii00 cctt | tttt tttt | tt00 0000 | 000b TTxx | xx00 + # I: 0 - sensor 2, 1 - sensor 1 + # i: random id (changes on power-loss) + # c: Channel + # t: Temperature + # b: battery indicator (0=>OK, 1=>LOW) + # T: Temperature trend + # x: crc4 + # + # $temp = (oct("0b". substr($bitData,22,4) . substr($bitData,18,4) . substr($bitData,14,4)) - 1220) * 5 / 90.0; + # $batbit = substr($bitData,35,1) eq "0" ? 1 : 0; + # $channel = substr($bitData,2,1) eq "0" ? 2 : 1; + # $trend = oct("0b".substr($bitData,36,2)); + # if ($trend == 1 || $trend == 2) { # falling und rising tauschen + # $trend ^= 3; + # } + # $model = "NX7674"; + # + # if ( $enableLongIDs == TRUE || (($longids ne "0") && ($longids eq "1" || $longids eq "ALL" || (",$longids," =~ m/,$model,/)))) + # { + # Log3 $hash,4, "$iodev: CUL_TCM97001 using longid: $longids model: $model"; + # } else { + # $deviceCode="CUL_TCM97001_" . $model . "_" . $channel; + # } + # $def = $modules{CUL_TCM97001}{defptr}{$deviceCode}; + # if($def) { + # $name = $def->{NAME}; + # } else { + # goto UNDEFINED_MODEL; + # } + # + # $hasbatcheck = TRUE; + # $haschannel = TRUE; + # $hastrend = TRUE; + # $packageOK = TRUE; + # + # $readedModel=$model; + # } #Log3 $name, 4, "CUL_TCM97001: CRC for TCM21.... Failed, checking other protocolls"; # Check for Prologue @@ -1645,7 +1726,7 @@ CUL_TCM97001_Parse($$) $batbit = ~$batbit & 0x1; # Bat bit umdrehen $mode = (hex($a[3]) & 0x8) >> 3; $trend = hex($a[3]) & 0x3; - $channel = (hex($a[10])) & 0x3; + $channel = (hex($a[9])) & 0x3; $model="Auriol_IAN"; @@ -1670,7 +1751,7 @@ CUL_TCM97001_Parse($$) $hashumidity = TRUE; #} $hasbatcheck = TRUE; - $haschannel = FALSE; + $haschannel = TRUE; $hasmode = TRUE; $hastrend = TRUE; $packageOK = TRUE; @@ -1867,6 +1948,63 @@ CUL_TCM97001_Parse($$) $name = $nameUnknown; } } + } elsif (length($msg) == 14) { + my $hlen = length($msg); + my $blen = $hlen * 4; + my $bitData = unpack("B$blen", pack("H$hlen", $msg)); + my $idType1 = hex($a[0] . $a[1]); + $deviceCode = "CUL_TCM97001_" . $idType1; + $def = $modules{CUL_TCM97001}{defptr}{$deviceCode}; + if($def) { + $name = $def->{NAME}; + } + $readedModel = AttrVal($name, "model", "Unknown"); + Log3 $iodev, 4, "$iodev: CUL_TCM97001 Parse Name: $name , devicecode: $deviceCode, Model defined: $readedModel"; + + if (checkCRC_sduinoID33($hash,$bitData) == TRUE && ($readedModel eq "Unknown" || $readedModel eq "NX7674")) { + # https://forum.fhem.de/index.php?topic=135692.0 + # Rosenstein & Soehne, Kuehl- & Gefrierschrank-Thermometer + # + # 0 4 | 8 12 | 16 20 | 24 28 | 32 36 | 40 + # 00Ii iiii | ii00 cctt | tttt tttt | tt00 0000 | 000b TTxx | xx00 + # I: 0 - sensor 1, 1 - sensor 2 + # i: random id (changes on power-loss) + # c: Channel + # t: Temperature + # b: battery indicator (0=>OK, 1=>LOW) + # T: Temperature trend + # x: crc4 + # + # dmsg s114735400540E3 T: 15.6, Bat: ok, CH: 1 + $temp = (oct("0b". substr($bitData,22,4) . substr($bitData,18,4) . substr($bitData,14,4)) - 1220) * 5 / 90.0; + $batbit = substr($bitData,35,1) eq "0" ? 1 : 0; + $channel = substr($bitData,2,1) eq "0" ? 1 : 2; + $trend = oct("0b".substr($bitData,36,2)); + if ($trend == 1 || $trend == 2) { # falling und rising tauschen + $trend ^= 3; + } + $model = "NX7674"; + + if ( $enableLongIDs == TRUE || (($longids ne "0") && ($longids eq "1" || $longids eq "ALL" || (",$longids," =~ m/,$model,/)))) + { + Log3 $hash,4, "$iodev: CUL_TCM97001 using longid: $longids model: $model"; + } else { + $deviceCode="CUL_TCM97001_" . $model . "_" . $channel; + } + $def = $modules{CUL_TCM97001}{defptr}{$deviceCode}; + if($def) { + $name = $def->{NAME}; + } else { + goto UNDEFINED_MODEL; + } + + $hasbatcheck = TRUE; + $haschannel = TRUE; + $hastrend = TRUE; + $packageOK = TRUE; + + $readedModel=$model; + } } # Ignoriere dieses Geraet. Das Geraet wird keine FileLogs/notifys triggern, empfangene Befehle @@ -2243,7 +2381,7 @@ sub do_undefModelReading { =begin html_DE - +

CUL_TCM97001