Skip to content

Commit

Permalink
41_OREGON.pm
Browse files Browse the repository at this point in the history
Fixes
anpassungen für OSV3
neue Sensoren
  • Loading branch information
Ralf9 committed Dec 7, 2015
1 parent 0716e01 commit 569b256
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions FHEM/41_OREGON.pm
Expand Up @@ -147,7 +147,7 @@ my %types =
},
OREGON_type_length_key(0xda78, 72) =>
{
part => 'UVN800', checksun => \&OREGON_checksum7, method => \&OREGON_uvn800,
part => 'UVN800', checksum => \&OREGON_checksum7, method => \&OREGON_uvn800,
},
OREGON_type_length_key(0xea7c, 120) =>
{
Expand All @@ -158,7 +158,7 @@ my %types =
part => 'THWR288A', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
#
OREGON_type_length_key(0xea4c, 68) =>
OREGON_type_length_key(0xea4c, 64) =>
{
part => 'THN132N', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
Expand Down Expand Up @@ -236,6 +236,15 @@ my %types =
{
part => 'PCR800', checksum => \&OREGON_checksum8, method => \&OREGON_rain_PCR800,
},
# THWR800
OREGON_type_length_key(0xca48, 68) =>
{
part => 'THWR800', checksum => \&OREGON_checksum9, method => \&OREGON_common_temp,
},
OREGON_type_length_key(0x0adc, 64) => # masked to ?adc due to rolling code
{
part => 'RTHN318', checksum => \&OREGON_checksum1, method => \&OREGON_common_temp,
},
);

# --------------------------------------------
Expand Down Expand Up @@ -798,7 +807,10 @@ sub OREGON_checksum1 {
}

sub OREGON_checksum2 {
$_[0]->[8] == ((OREGON_nibble_sum(8,$_[0]) - 0xa) & 0xff);

This comment has been minimized.

Copy link
@Ralf9

Ralf9 Feb 9, 2016

Author Contributor

ich möchte hier Log 3 in Log3 $hash, 5, ersetzen
Ich bin mir nicht ganz sicher wie ich den $iohash übergeben soll.
Kann ich hier my $hash = $_[1]; schreiben?

Und in der OREGON_Parse($$) dann:
if ($checksum && !$checksum->(\@rfxcom_data_array, $iohash) ) {

This comment has been minimized.

Copy link
@sidey79

sidey79 Feb 9, 2016

Contributor

Hmm,

also bei der Übergabe der Liste als Referenz bin ich mir nicht sicher.
Ich konnte auf die Schnelle jetzt nicht finden, welche Funktion da aufgerufen wird.

Sofern die Parameter der übergeben ein Liste als @_[0] ausgewertet werden ist das letzte Element der Hash oder Name.
Den kannst Du mit $name= pop; abrufen.

This comment has been minimized.

Copy link
@Ralf9

Ralf9 Feb 9, 2016

Author Contributor

Ich habe es einfach mal so versucht. Das $name habe ich nur zum Testen eingefügt.
Es funktioniert wie gewünscht.
Spricht was dagegen dies so zu machen?

sub OREGON_checksum8 {
  my $hash = $_[1];
  my $name = $hash->{NAME};
  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);
  Log3 $hash, 5, "OREGON: $name checksum8 = $c berechnet: $s";
  $s == $c;
}

This comment has been minimized.

Copy link
@sidey79

sidey79 Feb 9, 2016

Contributor

Ich würde my $hash = pop; machen :) Und vermutlich gleich den Namen und nicht den hash übergeben, denn in log3 wird ja dann auch nur wieder der name aus $hash extrahiert.

my $c = $_[0]->[8];
my $s = ((OREGON_nibble_sum(8,$_[0]) - 0xa) & 0xff);
Log 3, "OREGON: checksum2 = $c berechnet: $s";
$s == $c;
}

sub OREGON_checksum3 {
Expand Down Expand Up @@ -830,10 +842,19 @@ sub OREGON_checksum7 {

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

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


sub OREGON_raw {
$_[0]->{raw} or $_[0]->{raw} = pack 'H*', $_[0]->{hex};
}
Expand Down

0 comments on commit 569b256

Please sign in to comment.