mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
14_CUL_TCM97001: Fix some uninitialized vars, update docu
git-svn-id: https://svn.fhem.de/fhem/trunk@8590 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b9ed47c838
commit
f7c7c1706f
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix: 14_CUL_TCM97001: Fix some uninitialized vars, update docu
|
||||||
- feature: 30_pilight_temp: attribut corrHumidity to correct humidity
|
- feature: 30_pilight_temp: attribut corrHumidity to correct humidity
|
||||||
- feature: 76_MSGMail: Add attribute mailtype as suggested by Roger
|
- feature: 76_MSGMail: Add attribute mailtype as suggested by Roger
|
||||||
(forum #37206)
|
(forum #37206)
|
||||||
|
@ -149,7 +149,9 @@ sub checkCRC_GTWT02 {
|
|||||||
sub checkValues {
|
sub checkValues {
|
||||||
my $temp = shift;
|
my $temp = shift;
|
||||||
my $humidy = shift;
|
my $humidy = shift;
|
||||||
|
if (!defined($humidy)) {
|
||||||
|
$humidy = 50;
|
||||||
|
}
|
||||||
if ($temp < 60 && $temp > -30
|
if ($temp < 60 && $temp > -30
|
||||||
&& $humidy > 0 && $humidy < 100) {
|
&& $humidy > 0 && $humidy < 100) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -185,11 +187,17 @@ CUL_TCM97001_Parse($$)
|
|||||||
|
|
||||||
my $rssi;
|
my $rssi;
|
||||||
my $l = length($msg);
|
my $l = length($msg);
|
||||||
$rssi = hex(substr($msg, $l-2, 2));
|
$rssi = substr($msg, $l-2, 2);
|
||||||
$rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74));
|
undef($rssi) if ($rssi eq "00");
|
||||||
|
|
||||||
#Log3 $name, 4, "CUL_TCM97001 $name $id3 or $id4 ($msg) length:" . length($msg) . " RSSI: $rssi";
|
if (defined($rssi))
|
||||||
Log3 $name, 4, "CUL_TCM97001 $name $id3 ($msg) length:" . length($msg) . " RSSI: $rssi";
|
{
|
||||||
|
$rssi = hex($rssi);
|
||||||
|
$rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74)) if defined($rssi);
|
||||||
|
Log3 $name, 4, "CUL_TCM97001 $name $id3 ($msg) length: $l RSSI: $rssi";
|
||||||
|
} else {
|
||||||
|
Log3 $name, 4, "CUL_TCM97001 $name $id3 ($msg) length: $l";
|
||||||
|
}
|
||||||
|
|
||||||
my ($msgtype, $msgtypeH);
|
my ($msgtype, $msgtypeH);
|
||||||
|
|
||||||
@ -253,7 +261,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
if (checkValues($temp, 50)) {
|
if (checkValues($temp, 50)) {
|
||||||
if(!$def) {
|
if(!$def) {
|
||||||
Log3 $name, 2, "CUL_TCM97001 Unknown device $tcm97id, please define it";
|
Log3 $name, 2, "CUL_TCM97001 Unknown device $tcm97id, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_$tcm97id CUL_TCM97001 $tcm97id" if(!$def);
|
return "UNDEFINED CUL_TCM97001_$tcm97id CUL_TCM97001 $tcm97id";
|
||||||
}
|
}
|
||||||
$packageOK = TRUE;
|
$packageOK = TRUE;
|
||||||
$hasbatcheck = TRUE;
|
$hasbatcheck = TRUE;
|
||||||
@ -273,11 +281,11 @@ CUL_TCM97001_Parse($$)
|
|||||||
$temp = -$temp;
|
$temp = -$temp;
|
||||||
}
|
}
|
||||||
$batbit = ((hex($a[4]) & 0x8) != 0x8);
|
$batbit = ((hex($a[4]) & 0x8) != 0x8);
|
||||||
|
$mode = (hex($a[4]) & 0x4) >> 2;
|
||||||
if (checkValues($temp, 50)) {
|
if (checkValues($temp, 50)) {
|
||||||
if(!$def) {
|
if(!$def) {
|
||||||
Log3 $name, 2, "CUL_TCM97001 Unknown device $tcm97id, please define it";
|
Log3 $name, 2, "CUL_TCM97001 Unknown device $tcm97id, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_$tcm97id CUL_TCM97001 $tcm97id" if(!$def);
|
return "UNDEFINED CUL_TCM97001_$tcm97id CUL_TCM97001 $tcm97id";
|
||||||
}
|
}
|
||||||
$hasbatcheck = TRUE;
|
$hasbatcheck = TRUE;
|
||||||
$packageOK = TRUE;
|
$packageOK = TRUE;
|
||||||
@ -315,6 +323,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
# C Bit 1 Battery
|
# C Bit 1 Battery
|
||||||
# D+E+F Temp
|
# D+E+F Temp
|
||||||
# G+H Hum
|
# G+H Hum
|
||||||
|
# I CRC
|
||||||
$def = $modules{CUL_TCM97001}{defptr}{$idType1};
|
$def = $modules{CUL_TCM97001}{defptr}{$idType1};
|
||||||
if($def) {
|
if($def) {
|
||||||
$name = $def->{NAME};
|
$name = $def->{NAME};
|
||||||
@ -331,12 +340,11 @@ CUL_TCM97001_Parse($$)
|
|||||||
#Split reversed a again
|
#Split reversed a again
|
||||||
my @aReverse = split("", $hexReverse);
|
my @aReverse = split("", $hexReverse);
|
||||||
|
|
||||||
my $CRC = (hex($aReverse[0])+hex($aReverse[1])+hex($aReverse[2])+hex($aReverse[3])
|
|
||||||
+hex($aReverse[4])+hex($aReverse[5])+hex($aReverse[6])+hex($aReverse[7])) & 15;
|
|
||||||
|
|
||||||
if (hex($aReverse[5]) > 3) {
|
if (hex($aReverse[5]) > 3) {
|
||||||
# negative temp
|
# negative temp
|
||||||
$temp = ((-hex($aReverse[3]) + -hex($aReverse[4]) * 16 + -hex($aReverse[5]) * 256)+1+4096)/10;
|
$temp = ((hex($aReverse[3]) + hex($aReverse[4]) * 16 + hex($aReverse[5]) * 256));
|
||||||
|
$temp = (~$temp & 0x03FF) + 1;
|
||||||
|
$temp = -$temp/10;
|
||||||
} else {
|
} else {
|
||||||
# positive temp
|
# positive temp
|
||||||
$temp = (hex($aReverse[3]) + hex($aReverse[4]) * 16 + hex($aReverse[5]) * 256)/10;
|
$temp = (hex($aReverse[3]) + hex($aReverse[4]) * 16 + hex($aReverse[5]) * 256)/10;
|
||||||
@ -349,7 +357,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
if (checkValues($temp, $humidity)) {
|
if (checkValues($temp, $humidity)) {
|
||||||
if(!$def) {
|
if(!$def) {
|
||||||
Log3 $name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
Log3 $name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1" if(!$def);
|
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1";
|
||||||
}
|
}
|
||||||
$hashumidity = TRUE;
|
$hashumidity = TRUE;
|
||||||
$packageOK = TRUE;
|
$packageOK = TRUE;
|
||||||
@ -387,12 +395,12 @@ CUL_TCM97001_Parse($$)
|
|||||||
|
|
||||||
if (checkValues($temp, $humidity)) {
|
if (checkValues($temp, $humidity)) {
|
||||||
if(!$def) {
|
if(!$def) {
|
||||||
#Log3 $name, 2, "CUL_TCM97001 Unknown device $idType3, please define it";
|
|
||||||
#return "UNDEFINED CUL_TCM97001_$idType3 CUL_TCM97001 $idType3" if(!$def);
|
|
||||||
$name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
$name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1" if(!$def);
|
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1";
|
||||||
|
}
|
||||||
|
if ($humidity >= 20) {
|
||||||
|
$hashumidity = TRUE;
|
||||||
}
|
}
|
||||||
$hashumidity = TRUE;
|
|
||||||
$hasbatcheck = TRUE;
|
$hasbatcheck = TRUE;
|
||||||
$haschannel = TRUE;
|
$haschannel = TRUE;
|
||||||
$packageOK = TRUE;
|
$packageOK = TRUE;
|
||||||
@ -428,7 +436,6 @@ CUL_TCM97001_Parse($$)
|
|||||||
$temp = $temp / 10;
|
$temp = $temp / 10;
|
||||||
|
|
||||||
if (hex($a[7]) != 0xC && hex($a[8]) != 0xC) {
|
if (hex($a[7]) != 0xC && hex($a[8]) != 0xC) {
|
||||||
$hashumidity = TRUE;
|
|
||||||
$humidity = hex($a[7].$a[8]);
|
$humidity = hex($a[7].$a[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,11 +445,13 @@ CUL_TCM97001_Parse($$)
|
|||||||
if (checkValues($temp, $humidity)) {
|
if (checkValues($temp, $humidity)) {
|
||||||
if(!$def) {
|
if(!$def) {
|
||||||
Log3 $name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
Log3 $name, 2, "CUL_TCM97001 Unknown device $idType1, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1" if(!$def);
|
return "UNDEFINED CUL_TCM97001_$idType1 CUL_TCM97001 $idType1";
|
||||||
# Log3 $name, 2, "CUL_TCM97001 Unknown device $idType3, please define it";
|
}
|
||||||
# return "UNDEFINED CUL_TCM97001_$idType3 CUL_TCM97001 $idType3" if(!$def);
|
if (defined($humidity)) {
|
||||||
|
if ($humidity >= 20) {
|
||||||
|
$hashumidity = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$hashumidity = TRUE;
|
|
||||||
$hasbatcheck = TRUE;
|
$hasbatcheck = TRUE;
|
||||||
$packageOK = TRUE;
|
$packageOK = TRUE;
|
||||||
$haschannel = TRUE;
|
$haschannel = TRUE;
|
||||||
@ -592,26 +601,18 @@ CUL_TCM97001_Parse($$)
|
|||||||
my ($val, $valH, $state);
|
my ($val, $valH, $state);
|
||||||
$msgtype = "temperature";
|
$msgtype = "temperature";
|
||||||
$val = sprintf("%2.1f", ($temp) );
|
$val = sprintf("%2.1f", ($temp) );
|
||||||
|
$state="T: $val";
|
||||||
if ($hashumidity == TRUE) {
|
if ($hashumidity == TRUE) {
|
||||||
$msgtypeH = "humidity";
|
$msgtypeH = "humidity";
|
||||||
$valH = $humidity;
|
$valH = $humidity;
|
||||||
|
$state="$state H: $valH";
|
||||||
Log3 $name, 4, "CUL_TCM97001 $msgtype $name $id3 T: $val H: $valH";
|
Log3 $name, 4, "CUL_TCM97001 $msgtype $name $id3 T: $val H: $valH";
|
||||||
} else {
|
} else {
|
||||||
Log3 $name, 4, "CUL_TCM97001 $msgtype $name $id3 T: $val";
|
Log3 $name, 4, "CUL_TCM97001 $msgtype $name $id3 T: $val";
|
||||||
}
|
}
|
||||||
#Log3 $name, 2, "xxxxxxxx $model ......... $name .......... $val .... $valH ... $def";
|
|
||||||
my $t = ReadingsVal($name, "temperature", undef);
|
|
||||||
my $h = ReadingsVal($name, "humidity", undef);
|
|
||||||
if(defined($t) && defined($h)) {
|
|
||||||
$state="T: $t H: $h";
|
|
||||||
} elsif(defined($t)) {
|
|
||||||
$state="T: $t";
|
|
||||||
} elsif(defined($h)) {
|
|
||||||
$state="H: $h";
|
|
||||||
}
|
|
||||||
|
|
||||||
readingsBeginUpdate($def);
|
readingsBeginUpdate($def);
|
||||||
readingsBulkUpdate($def, "state", $state);
|
|
||||||
|
|
||||||
if($hastrend) {
|
if($hastrend) {
|
||||||
my $readTrend = ReadingsVal($name, "trend", "unknown");
|
my $readTrend = ReadingsVal($name, "trend", "unknown");
|
||||||
@ -630,13 +631,16 @@ CUL_TCM97001_Parse($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($haschannel) {
|
if ($haschannel) {
|
||||||
my $readChannel = ReadingsVal($name, "channel", undef);
|
my $readChannel = ReadingsVal($name, "channel", "");
|
||||||
if ($readChannel ne $channel) { readingsBulkUpdate($def, "channel", $channel); }
|
if (defined($readChannel) && $readChannel ne $channel) { readingsBulkUpdate($def, "channel", $channel); }
|
||||||
}
|
}
|
||||||
readingsBulkUpdate($def, $msgtype, $val);
|
readingsBulkUpdate($def, $msgtype, $val);
|
||||||
if ($hashumidity == TRUE) {
|
if ($hashumidity == TRUE) {
|
||||||
readingsBulkUpdate($def, $msgtypeH, $valH);
|
readingsBulkUpdate($def, $msgtypeH, $valH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readingsBulkUpdate($def, "state", $state);
|
||||||
|
|
||||||
readingsEndUpdate($def, 1);
|
readingsEndUpdate($def, 1);
|
||||||
if(defined($rssi)) {
|
if(defined($rssi)) {
|
||||||
$def->{RSSI} = $rssi;
|
$def->{RSSI} = $rssi;
|
||||||
@ -648,7 +652,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
|
|
||||||
if (!$defUnknown) {
|
if (!$defUnknown) {
|
||||||
Log3 "Unknown", 2, "CUL_TCM97001 Unknown device Unknown, please define it";
|
Log3 "Unknown", 2, "CUL_TCM97001 Unknown device Unknown, please define it";
|
||||||
return "UNDEFINED CUL_TCM97001_Unknown CUL_TCM97001 Unknown" if(!$defUnknown);
|
return "UNDEFINED CUL_TCM97001_Unknown CUL_TCM97001 Unknown";
|
||||||
}
|
}
|
||||||
$name = $defUnknown->{NAME};
|
$name = $defUnknown->{NAME};
|
||||||
Log3 $name, 4, "CUL_TCM97001 Device not implemented yet name Unknown msg $msg";
|
Log3 $name, 4, "CUL_TCM97001 Device not implemented yet name Unknown msg $msg";
|
||||||
@ -688,7 +692,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
<a name="CUL_TCM97001"></a>
|
<a name="CUL_TCM97001"></a>
|
||||||
<h3>CUL_TCM97001</h3>
|
<h3>CUL_TCM97001</h3>
|
||||||
<ul>
|
<ul>
|
||||||
The CUL_TCM97001 module interprets temperature sensor messages received by the CUL.<br>
|
The CUL_TCM97001 module interprets temperature sensor messages received by a Device like CUL, CUN, SIGNALduino etc.<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Supported models:</b>
|
<b>Supported models:</b>
|
||||||
<ul>
|
<ul>
|
||||||
@ -725,8 +729,8 @@ CUL_TCM97001_Parse($$)
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a href="#IODev">IODev</a>
|
<li><a href="#IODev">IODev</a>
|
||||||
Note: by setting this attribute you can define different sets of 8
|
Note: by setting this attribute you can define different sets of 8
|
||||||
devices in FHEM, each set belonging to a CUL. It is important, however,
|
devices in FHEM, each set belonging to a Device which is capable of receiving the signals. It is important, however,
|
||||||
that a device is only received by the CUL defined, e.g. by using
|
that a device is only received by the defined IO Device, e.g. by using
|
||||||
different Frquencies (433MHz vs 868MHz)
|
different Frquencies (433MHz vs 868MHz)
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#do_not_notify">do_not_notify</a></li>
|
<li><a href="#do_not_notify">do_not_notify</a></li>
|
||||||
@ -751,7 +755,7 @@ CUL_TCM97001_Parse($$)
|
|||||||
<a name="CUL_TCM97001"></a>
|
<a name="CUL_TCM97001"></a>
|
||||||
<h3>CUL_TCM97001</h3>
|
<h3>CUL_TCM97001</h3>
|
||||||
<ul>
|
<ul>
|
||||||
Das CUL_TCM97001 Module verarbeitet vom CUL empfangene Nachrichten von Temperatur-Sensoren.<br>
|
Das CUL_TCM97001 Module verarbeitet von einem IO Gerät (CUL, CUN, SIGNALDuino, etc.) empfangene Nachrichten von Temperatur-Sensoren.<br>
|
||||||
<br>
|
<br>
|
||||||
<b>Unterstütze Modelle:</b>
|
<b>Unterstütze Modelle:</b>
|
||||||
<ul>
|
<ul>
|
||||||
@ -789,8 +793,6 @@ CUL_TCM97001_Parse($$)
|
|||||||
<li><a href="#IODev">IODev</a>
|
<li><a href="#IODev">IODev</a>
|
||||||
Spezifiziert das physische Gerät, das die Ausstrahlung der Befehle für das
|
Spezifiziert das physische Gerät, das die Ausstrahlung der Befehle für das
|
||||||
"logische" Gerät ausführt. Ein Beispiel für ein physisches Gerät ist ein CUL.<br>
|
"logische" Gerät ausführt. Ein Beispiel für ein physisches Gerät ist ein CUL.<br>
|
||||||
Anmerkung: Beim Start weist fhem einem InterTechno-Gerät kein IO-Gerät zu.
|
|
||||||
Das Attribut IODev ist daher IMMER zu setzen.
|
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#do_not_notify">do_not_notify</a></li>
|
<li><a href="#do_not_notify">do_not_notify</a></li>
|
||||||
<li><a href="#ignore">ignore</a></li>
|
<li><a href="#ignore">ignore</a></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user