Skip to content

Commit

Permalink
41_OREGON.pm
Browse files Browse the repository at this point in the history
verbesserte Log Meldungen
Device specific help ergänzt
  • Loading branch information
Ralf9 committed Feb 9, 2016
1 parent f042b26 commit d20550e
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions FHEM/41_OREGON.pm
@@ -1,5 +1,5 @@
#################################################################################
# $Id: 41_OREGON.pm 34475 2016-02-08 18:00:00 wherzig $
# $Id: 41_OREGON.pm 34476 2016-02-09 21:00:00 wherzig $
#
# Module for FHEM to decode Oregon sensor messages
#
Expand Down Expand Up @@ -57,7 +57,7 @@ OREGON_Initialize($)
$hash->{DefFn} = "OREGON_Define";
$hash->{UndefFn} = "OREGON_Undef";
$hash->{ParseFn} = "OREGON_Parse";
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 loglevel:0,1,2,3,4,5,6"
$hash->{AttrList} = "IODev ignore:0,1 do_not_notify:1,0 showtime:1,0"
." $readingFnAttributes";
}

Expand Down Expand Up @@ -160,11 +160,15 @@ my %types =
{
part => 'THWR288A', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
#
# THN132N
OREGON_type_length_key(0xea4c, 64) =>
{
part => 'THN132N', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
OREGON_type_length_key(0xea4c, 68) =>
{
part => 'THN132N', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
#
OREGON_type_length_key(0x9aec, 104) =>
{
Expand Down Expand Up @@ -804,15 +808,18 @@ sub OREGON_rain_PCR800 {
# CHECKSUM METHODS

sub OREGON_checksum1 {
my $hash = $_[1];
my $c = OREGON_hi_nibble($_[0]->[6]) + (OREGON_lo_nibble($_[0]->[7]) << 4);
my $s = ( ( OREGON_nibble_sum(6, $_[0]) + OREGON_lo_nibble($_[0]->[6]) - 0xa) & 0xff);
Log3 $hash, 5, "OREGON: checksum1 = $c berechnet: $s";
$s == $c;
}

sub OREGON_checksum2 {
my $hash = $_[1];
my $c = $_[0]->[8];
my $s = ((OREGON_nibble_sum(8,$_[0]) - 0xa) & 0xff);
Log 4, "OREGON: checksum2 = $c berechnet: $s";
Log3 $hash, 5, "OREGON: checksum2 = $c berechnet: $s";
$s == $c;
}

Expand All @@ -834,8 +841,10 @@ sub OREGON_checksum6 {
}

sub OREGON_checksum6plus {
my $hash = $_[1];
my $c = OREGON_hi_nibble($_[0]->[8]) + (OREGON_lo_nibble($_[0]->[9]) << 4);
my $s = (((OREGON_nibble_sum(8,$_[0]) + (($_[0]->[8] & 0x0f) - 0x00)) - 0xa) & 0xff);
Log3 $hash, 5, "OREGON: checksum6plus = $c berechnet: $s";
$s == $c;
}

Expand All @@ -844,16 +853,18 @@ sub OREGON_checksum7 {
}

sub OREGON_checksum8 {
my $hash = $_[1];
my $c = OREGON_hi_nibble($_[0]->[9]) + (OREGON_lo_nibble($_[0]->[10]) << 4);
my $s = ( ( OREGON_nibble_sum(9, $_[0]) + OREGON_lo_nibble($_[0]->[9]) - 0xa) & 0xff);
Log 4, "OREGON: checksum8 = $c berechnet: $s";
Log3 $hash, 5, "OREGON: checksum8 = $c berechnet: $s";
$s == $c;
}

sub OREGON_checksum9 {
my $hash = $_[1];
my $c = OREGON_hi_nibble($_[0]->[6]) + (OREGON_lo_nibble($_[0]->[7]) << 4);
my $s = ((OREGON_nibble_sum(6,$_[0]) - 0xa) & 0xff);
Log 4, "OREGON: checksum8 = $c berechnet: $s";
Log3 $hash, 5, "OREGON: checksum9 = $c berechnet: $s";
$s == $c;
}

Expand Down Expand Up @@ -915,7 +926,7 @@ OREGON_Parse($$)

# test checksum as defines in %types:
my $checksum = $rec->{checksum};
if ($checksum && !$checksum->(\@rfxcom_data_array) ) {
if ($checksum && !$checksum->(\@rfxcom_data_array, $iohash) ) {
Log3 $iohash, 4, "OREGON: ERROR: checksum error sensor_id=$sensor_id (bits=$bits)";
return "OREGON: ERROR: checksum error sensor_id=$sensor_id (bits=$bits)";
}
Expand Down Expand Up @@ -1105,9 +1116,9 @@ OREGON_Parse($$)
<a name="OREGON"></a>
<h3>OREGON</h3>
<ul>
The OREGON module interprets Oregon sensor messages received by a RFXCOM receiver. You need to define a RFXCOM receiver first.
The OREGON module interprets Oregon sensor messages received by a RFXCOM or SIGNALduino receiver. You need to define a receiver (RFXCOM or SIGNALduino) first.
See <a href="#RFXCOM">RFXCOM</a>.
See <a href="#SIGNALduino">SIGNALduino</a>.
<br><br>
<a name="OREGONdefine"></a>
Expand Down Expand Up @@ -1135,8 +1146,11 @@ The one byte hex string is generated by the Oregon sensor when is it powered on.
<a name="OREGONattr"></a>
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#IODev">IODev</a></li>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul>
</ul>
Expand Down

2 comments on commit d20550e

@Ralf9
Copy link
Contributor Author

@Ralf9 Ralf9 commented on d20550e Feb 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich habe dies nicht übernommen
http://forum.fhem.de/index.php/topic,41929.msg341622.html#msg341622

Ich sehe dabei das Problem, daß ein undef als Rückgabe die Unknown Meldungen im log erzeugt.
Bei einem nicht so gutem Empfang würde jede fehlerhaft empfangene Nachricht eine Unknown Meldung im log erzeugen.
Um diese Unknown Meldungen zu unterdrücken müssten auch die Oregon Nachrichten von einem weitern Modul verarbeitet werden.

@sidey79
Copy link
Contributor

@sidey79 sidey79 commented on d20550e Feb 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gut zu wissen. Undef ist aber meiner Meinung nach die Wahl, wenn das Modul nichts mit der Nachricht anfangen kann.

Please sign in to comment.