Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new protocol 117 for BRESSER 7-in-1 Weather Center #1072

Merged
merged 7 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
2022-01-25 - 00_SIGNALduino.pm

- Correct Versionnumber
2022-01-25 - Update {Match} regex for Hideki Module (#1071)

2022-01-25 - Update {Match} regex for Hideki Module (#1071)
* 14_Hideki.pm

- Match Regex angepasst
- Subs als Coderef hinterlegt

* 09_ParseData.t

- ParseData Test mit Testdaten hinterlegt
2022-01-24 - Prüfung ergänzt, welche dmsg gegen den Match Eintrag verifiziert (#1065)

2022-01-24 - Prüfung ergänzt, welche dmsg gegen den Match Eintrag verifiziert (#1065)
* lib/Test2/SIGNALduino/RDmsg.pm

- Prüfung ergänzt, welche dmsg gegen den Match eintrag verifiziert

* t/FHEM/10_SD_Rojaflex

- marked to short testdata as failable for match check

* 14_SD_UT.pm

Match Regex angepast
56 fehlte
91.1 Syntax korrigiert
2022-01-23 - Version 3.5.4+ hinterlegt (#1069)

2022-01-23 - Version 3.5.4+ hinterlegt (#1069)
* Version 3.5.4+ hinterlegt

2022-01-23 - Master 3.5.3 (#1068)

Release 3.5.3
Expand Down
12 changes: 9 additions & 3 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 00_SIGNALduino.pm v3.5.4 2022-01-23 10:53:46Z sidey79 $
# $Id: 00_SIGNALduino.pm v3.5.4 2022-01-29 20:27:23Z elektron-bbs $
# v3.5.4 - https://github.com/RFD-FHEM/RFFHEM/tree/master
# The module is inspired by the FHEMduino project and modified in serval ways for processing the incoming messages
# see http://www.fhemwiki.de/wiki/SIGNALDuino
Expand Down Expand Up @@ -38,7 +38,7 @@ use List::Util qw(first);


use constant {
SDUINO_VERSION => '3.5.4+20220125', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_VERSION => '3.5.2+20220129', # Datum wird automatisch bei jedem pull request aktualisiert
sidey79 marked this conversation as resolved.
Show resolved Hide resolved
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
Expand Down Expand Up @@ -4787,6 +4787,9 @@ USB-connected devices (SIGNALduino):<br>
<li>Bresser_6in1<br>
modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, frequency 868.35 MHz
</li>
<li>Bresser_7in1<br>
modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, frequency 868.35 MHz
</li>
<li>Fine_Offset_WH51_434<br>
Modulation 2-FSK, Datarate=17.26 kbps, Sync Word=2DD4, Packet Length=14 Byte, Frequency 433.92 MHz
<ul><small>Example: Soil moisture sensor Fine Offset WH51, ECOWITT WH51, MISOL/1, Froggit DP100</small></ul>
Expand Down Expand Up @@ -5356,7 +5359,7 @@ USB-connected devices (SIGNALduino):<br>
Konfiguriert den RF Transceiver des SIGNALduino (CC1101). Verf&uuml;gbare Argumente sind:
<ul>
<li>Avantek<br>
Modulation 2-FSK, Datarate=50.087 kbps, Sync Word=0869, FIFO-THR=8 Byte, Frequenz 433.3 MHz
Modulation 2-FSK, Datenrate=50.087 kbps, Sync Word=0869, FIFO-THR=8 Byte, Frequenz 433.3 MHz
<ul><small>Example: AVANTEK Funk-Türklingel</small></ul>
</li>
<li>Bresser_5in1<br>
Expand All @@ -5366,6 +5369,9 @@ USB-connected devices (SIGNALduino):<br>
<li>Bresser_6in1<br>
Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, Frequenz 868.35 MHz
</li>
<li>Bresser_7in1<br>
Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, Frequenz 868.35 MHz
</li>
<li>Fine_Offset_WH51_434<br>
Modulation 2-FSK, Datenrate=17.26 kbps, Sync Word=2DD4, Packet Length=14 Byte, Frequenz 433.92 MHz
<ul><small>Beispiel: Bodenfeuchtesensor Fine Offset WH51, ECOWITT WH51, MISOL/1, Froggit DP100</small></ul>
Expand Down
78 changes: 73 additions & 5 deletions FHEM/14_SD_WS.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 14_SD_WS.pm 21666 2022-01-15 12:25:06Z elektron-bbs $
# $Id: 14_SD_WS.pm 21666 2022-01-29 20:27:23Z elektron-bbs $
#
# The purpose of this module is to support serval
# weather sensors which use various protocol
Expand Down Expand Up @@ -40,6 +40,7 @@
# 05.01.2022 Protokoll 108: neuer Sensor Fody E42
# 08.01.2022 neues Protokoll 107: Soil Moisture Sensor Fine Offset WH51, ECOWITT WH51, MISOL/1, Froggit DP100
# 14.01.2022 neues Protokoll 116: Thunder and lightning sensor Fine Offset WH57, aka Froggit DP60, aka Ambient Weather WH31L
# 29.01.2022 neues Protokoll 117: Bresser 7-in-1 Comfort Wetter Center

package main;

Expand Down Expand Up @@ -91,10 +92,11 @@ sub SD_WS_Initialize {
'SD_WS_107_H.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => q{}, autocreateThreshold => '2:180'},
'SD_WS_108.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4:Temp,', autocreateThreshold => '5:120'},
'SD_WS_110_TR.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4:Temp,', autocreateThreshold => '3:180'},
'SD_WS_111_TL.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4:Temp,', autocreateThreshold => '3:600'},
'SD_WS_111_TL.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4:Temp,', autocreateThreshold => '3:600'},
'SD_WS_113_T.*' => { ATTR => 'event-min-interval:.*:60 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4:Temp,', autocreateThreshold => '10:180'},
'SD_WS_115.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4hum4:Temp/Hum,', autocreateThreshold => '5:120'},
'SD_WS_116.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => q{}, autocreateThreshold => '2:180'},
'SD_WS_117.*' => { ATTR => 'event-min-interval:.*:300 event-on-change-reading:.*', FILTER => '%NAME', GPLOT => 'temp4hum4:Temp/Hum,', autocreateThreshold => '5:120'},
};
return;
}
Expand Down Expand Up @@ -168,6 +170,7 @@ sub SD_WS_Parse {
my $distance;
my $uv;
my $adc;
my $brightness;
my $count;
my $identified;

Expand Down Expand Up @@ -1116,6 +1119,61 @@ sub SD_WS_Parse {
return 1;
}
} ,
117 => {
# https://github.com/merbanan/rtl_433/blob/master/src/devices/bresser_7in1.c
# The compact 7-in-1 multifunction outdoor sensor transmits the data on 868.3 MHz.
# The device uses FSK-PCM encoding, the device sends a transmission every 12 seconds.
# A transmission starts with a preamble of 0xAA.
# Preamble: aa aa aa aa aa 2d d4
#
# 1 2 3 4
# 01234567890123456789012345678901234567890123456789
# --------------------------------------------------
# 0CF0A6F5B98A10AAAAAAAAAAAAAABABC3EAABBFCAAAAAAAAAA000000 original message
# A65A0C5F1320BA000000000000001016940011560000000000AAAAAA message after all nibbles xor 0xA
# CCCCIIIIDDD??FGGGWWWRRRRRR??TTTBHHbbbbbbVVVttttttt
# C = LFSR-16 digest, generator 0x8810 key 0xba95 with a final xor 0x6df1, which likely means we got that wrong.
# I = station ID
# D = wind direction in degree, BCD coded, DDD = 158 => 158 °
# F = flags, 4 bit
# Bit: 0123
# 1010
# r???
# r: 1 bit device reset, 1 after inserting battery
# ???: always 010
# G = wind gust in 1/10 m/s, BCD coded, GGG = 123 => 12.3 m/s.
# W = wind speed in 1/10 m/s, BCD coded, WWW = 123 => 12.3 m/s.
# R = rain counter, in 0.1 mm, BCD coded RRRRRR = 000084 => 8.4 mm
# T = temperature in 1/10 °C, BCD coded, TTT = 312 => 31.2 °C
# B = battery. 0=Ok, 6=Low
# H = humidity in percent, BCD coded, HH = 23 => 23 %
# b = brightness, BCD coded, BBBBBB = 005584 => 5.584 klx
# V = uv, BCD coded, VVV = 012 => 1.2
# ? = unknown
# t = trailer
sensortype => 'Bresser_7in1',
model => 'SD_WS_117',
prematch => sub { return 1; }, # no precheck known
id => sub {my ($rawData,undef) = @_; return substr($rawData,4,4); },
winddir => sub {my ($rawData,undef) = @_;
$winddir = substr($rawData,8,3);
return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]);
},
batChange => sub {my (undef,$bitData) = @_; return substr($bitData,52,1) eq '0' ? '1' : '0';},
windgust => sub {my ($rawData,undef) = @_; return substr($rawData,14,3) * 0.1;},
windspeed => sub {my ($rawData,undef) = @_; return substr($rawData,17,3) * 0.1;},
rain => sub {my ($rawData,undef) = @_; return substr($rawData,20,6) * 0.1;},
temp => sub {my ($rawData,undef) = @_;
$rawTemp = substr($rawData,28,3) * 0.1;
if ($rawTemp > 60) {$rawTemp -= 100};
return $rawTemp;
},
bat => sub {my ($rawData,undef) = @_; return substr($rawData,31,1) eq '0' ? 'ok' : 'low';},
hum => sub {my ($rawData,undef) = @_; return substr($rawData,32,2) * 1;},
brightness => sub {my ($rawData,undef) = @_; return substr($rawData,34,6) * 0.001;},
uv => sub {my ($rawData,undef) = @_; return substr($rawData,40,3) * 0.1;},
crcok => sub {return 1;}, # checks are in SD_Protocols.pm sub ConvBresser_7in1
},
);

Log3 $name, 4, "$name: SD_WS_Parse protocol $protocol, rawData $rawData";
Expand Down Expand Up @@ -1455,6 +1513,7 @@ sub SD_WS_Parse {
$count = $decodingSubs{$protocol}{count}->( $rawData,$bitData ) if (exists($decodingSubs{$protocol}{count}));
$identified = $decodingSubs{$protocol}{identified}->( $rawData,$bitData ) if (exists($decodingSubs{$protocol}{identified}));
$uv = $decodingSubs{$protocol}{uv}->( $rawData,$bitData ) if (exists($decodingSubs{$protocol}{uv}));
$brightness = $decodingSubs{$protocol}{brightness}->( $rawData,$bitData ) if (exists($decodingSubs{$protocol}{brightness}));
Log3 $iohash, 4, "$name: SD_WS_Parse decoded protocol-id $protocol ($SensorTyp), sensor-id $id";
}
else {
Expand Down Expand Up @@ -1595,6 +1654,11 @@ sub SD_WS_Parse {
$state .= ' ' if (length($state) > 0);
$state .= "D: $distance";
}
if (defined($brightness)) {
$state .= ' ' if (length($state) > 0);
$state .= "B: $brightness";
}

### protocol 33 has different bits per sensor type
if ($protocol eq "33") {
if (AttrVal($name,'model',0) eq "S522") { # Conrad S522
Expand Down Expand Up @@ -1640,10 +1704,10 @@ sub SD_WS_Parse {
readingsBulkUpdate($hash, 'count', $count) if (defined($count));
readingsBulkUpdate($hash, 'identified', $identified) if (defined($identified));
readingsBulkUpdate($hash, "uv", $uv) if (defined($uv));
readingsBulkUpdate($hash, 'brightness', $brightness) if (defined($brightness));
readingsEndUpdate($hash, 1); # Notify is done by Dispatch

return $name;

}

#############################
Expand Down Expand Up @@ -1737,7 +1801,7 @@ sub SD_WS_WH2SHIFT {
<li>ADE WS1907 Weather station with rain gauge</li>
<li>Atech wireless weather station</li>
<li>BBQ temperature sensor GT-TMBBQ-01s (transmitter), GT-TMBBQ-01e (receiver)</li>
<li>Bresser 5-in-1 and 6-in-1 Comfort Weather Center, 7009994, Professional rain gauge, Temeo</li>
<li>Bresser 5-in-1, 6-in-1 and 7-in-1 Comfort Weather Center, 7009994, Professional rain gauge, Temeo</li>
<li>Conrad S522</li>
<li>EuroChron EFTH-800, EFS-3110A (temperature and humidity sensor)</li>
<li>Fine Offset WH51, aka ECOWITT WH51, aka Froggit DP100, aka MISOL/1 (soil moisture sensor)</li>
Expand Down Expand Up @@ -1787,6 +1851,7 @@ sub SD_WS_WH2SHIFT {
<li>batteryState (low or ok)</li>
<li>batteryVoltage (battery voltage in volts)</li>
<li>batteryPercent (battery level in %)</li>
<li>brightness (kLux)</li>
<li>channel (number of channel</li>
<li>distance (distance in cm (protocol 111) or km (protocol 116)</li>
<li>humidity (humidity (1-100 % only if available)</li>
Expand All @@ -1798,6 +1863,7 @@ sub SD_WS_WH2SHIFT {
<li>temperature (&deg;C)</li>
<li>temperatureTrend (consistent, rising, falling)</li>
<li>type (type of sensor)</li>
<li>uv (ultraviolet radiation)</li>
<li>windDirectionDegree (Wind direction, grad)</li>
<li>windDirectionText (Wind direction, N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW)</li>
<li>windGust (Gust of wind, m/s)</li>
Expand Down Expand Up @@ -1862,7 +1928,7 @@ sub SD_WS_WH2SHIFT {
<li>ADE WS1907 Wetterstation mit Regenmesser</li>
<li>Atech Wetterstation</li>
<li>BBQ Temperatur Sensor GT-TMBBQ-01s (Sender), GT-TMBBQ-01e (Empfaenger)</li>
<li>Bresser 5-in-1 und 6-in-1 Comfort Wetter Center, 7009994, Profi Regenmesser, Temeo</li>
<li>Bresser 5-in-1, 6-in-1 und 7-in-1 Comfort Wetter Center, 7009994, Profi Regenmesser, Temeo</li>
<li>Conrad S522</li>
<li>EuroChron EFTH-800, EFS-3110A (Temperatur- und Feuchtigkeitssensor)</li>
<li>Fine Offset WH51, aka ECOWITT WH51, aka Froggit DP100, aka MISOL/1 (Bodenfeuchtesensor)</li>
Expand Down Expand Up @@ -1913,6 +1979,7 @@ sub SD_WS_WH2SHIFT {
<li>batteryState (low oder ok)</li>
<li>batteryVoltage (Batteriespannung in Volt)</li>
<li>batteryPercent (Batteriestand in %)</li>
<li>brightness (Helligkeit in kLux)</li>
<li>channel (Sensor-Kanal)</li>
<li>distance (Entfernung in cm (Protokoll 111) oder km (Protokoll 116)</li>
<li>humidity (Luft-/Bodenfeuchte, 1-100 %)</li>
Expand All @@ -1924,6 +1991,7 @@ sub SD_WS_WH2SHIFT {
<li>temperature (Temperatur &deg;C)</li>
<li>temperatureTrend (Trend Temperatur gleichbleibend, steigend, fallend)</li>
<li>type (Sensortypen)</li>
<li>uv (Ultraviolettstrahlung)</li>
<li>windDirectionDegree (Windrichtung, Grad)</li>
<li>windDirectionText (Windrichtung, N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW)</li>
<li>windGust (Windboe, m/s)</li>
Expand Down
27 changes: 22 additions & 5 deletions FHEM/lib/SD_ProtocolData.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###########################################################################################################################################
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-23 10:53:46Z sidey79 $
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-29 20:27:23Z elektron-bbs $
# The file is part of the SIGNALduino project.
# All protocol definitions are contained in this file.
#
Expand Down Expand Up @@ -86,7 +86,7 @@ package lib::SD_ProtocolData;
use strict;
use warnings;

our $VERSION = '1.42';
our $VERSION = '1.43';

our %protocols = (
"0" => ## various weather sensors (500 | 9100)
Expand Down Expand Up @@ -3115,9 +3115,26 @@ package lib::SD_ProtocolData;
clientmodule => 'SD_WS',
length_min => '18',
},

# "117" => reserved @elektron-bbs for BRESSER 7-in-1 Weather Center

"117" => ## BRESSER 7-in-1 Weather Center
# https://forum.fhem.de/index.php/topic,78809.msg1196941.html#msg1196941 @ JensS 2021-12-30
# T: 12.7 H: 87 W: 0 R: 8.4 B: 6.676 MN;D=FC28A6F58DCA18AAAAAAAAAA2EAAB8DA2DAACCDCAAAAAAAAAA000000;R=29;
# T: 13.1 H: 88 W: 0 R: 0 B: 0.36 MN;D=4DC4A6F5B38A10AAAAAAAAAAAAAAB9BA22AAA9CAAAAAAAAAAA000000;R=15;
# T: 10.1 H: 94 W: 0 R: 0 B: 1.156 MN;D=0CF0A6F5B98A10AAAAAAAAAAAAAABABC3EAABBFCAAAAAAAAAA000000;R=28;
{
name => 'Bresser 7in1',
comment => 'BRESSER 7-in-1 weather center',
id => '117',
knownFreqs => '868.35',
datarate => '8.232',
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_7in1',
register => ['0001','022E','0345','042D','05D4','0616','07C0','0800','0D21','0E65','0FE8','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'],
preamble => 'W117#',
clientmodule => 'SD_WS',
length_min => '44',
method => \&lib::SD_Protocols::ConvBresser_7in1,
},
########################################################################
#### ### register informations from other hardware protocols #### ####

Expand Down
70 changes: 68 additions & 2 deletions FHEM/lib/SD_Protocols.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-22 16:38:42Z sidey79 $
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-29 20:27:23Z elektron-bbs $
#
# The file is part of the SIGNALduino project
# v3.5.x - https://github.com/RFD-FHEM/RFFHEM
Expand All @@ -16,7 +16,7 @@ use Carp qw(croak carp);
use constant HAS_DigestCRC => defined eval { require Digest::CRC; };
use constant HAS_JSON => defined eval { require JSON; };

our $VERSION = '2.05';
our $VERSION = '2.06';
use Storable qw(dclone);
use Scalar::Util qw(blessed);

Expand Down Expand Up @@ -1849,6 +1849,72 @@ sub ConvBresser_6in1 {
return $hexData;
}

=item ConvBresser_7in1()

This function makes xor 0xa over all bytes and checks LFSR_digest16

Input: $hexData
Output: $hexDataXorA
scalar converted message on success
or array (1,"Error message")

=cut

sub ConvBresser_7in1 {
my $self = shift // carp 'Not called within an object';
my $hexData = shift // croak 'Error: called without $hexdata as input';
my $hexLength = length($hexData);

return (1, 'ConvBresser_7in1, hexData is to short') if ($hexLength < 44); # check double, in def length_min set
return (1, 'ConvBresser_7in1, byte 21 is 0x00') if (substr($hexData,42,2) eq '00'); # check byte 21

my $hexDataXorA ='';
for (my $i = 0; $i < $hexLength; $i++) {
my $xor = hex(substr($hexData,$i,1)) ^ 0xA;
$hexDataXorA .= sprintf('%X',$xor);
}
$self->_logging(qq[ConvBresser_7in1, msg=$hexData],5);
$self->_logging(qq[ConvBresser_7in1, xor=$hexDataXorA],5);

my $checksum = lib::SD_Protocols::LFSR_digest16(20, 0x8810, 0xba95, substr($hexDataXorA,4,40));
my $checksumcalc = sprintf('%04X',$checksum ^ hex(substr($hexDataXorA,0,4)));
$self->_logging(qq[ConvBresser_7in1, checksumCalc:0x$checksumcalc, must be 0x6DF1],5);
return ( 1, qq[ConvBresser_7in1, checksumCalc:0x$checksumcalc != checksum:0x6DF1] ) if ($checksumcalc ne '6DF1');

return $hexDataXorA;
}

=item LFSR_digest16()

This function checks 16 bit LFSR

Input: $bytes, $gen, $key, $rawData
Output: $lfsr

=cut

sub LFSR_digest16 {
my ($bytes, $gen, $key, $rawData) = @_;
carp "LFSR_digest16, too few arguments ($bytes, $gen, $key, $rawData)" if @_ < 4;
return (1, 'LFSR_digest16, rawData is to short') if (length($rawData) < $bytes * 2);

my $lfsr = 0;
for (my $k = 0; $k < $bytes; $k++) {
my $data = hex(substr($rawData, $k * 2, 2));
for (my $i = 7; $i >= 0; $i--) {
if (($data >> $i) & 0x01) {
$lfsr ^= $key;
}
if ($key & 0x01) {
$key = ($key >> 1) ^ $gen;
} else {
$key = ($key >> 1);
}
}
}
return $lfsr;
}

############################# package lib::SD_Protocols, test exists
=item ConvPCA301()

Expand Down
Loading