From 0bd11a03ce09439b7e4d6cb771f59005517e7fbd Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Sun, 7 Aug 2022 18:19:38 +0200 Subject: [PATCH 01/12] Update SD_Protocols.pm --- FHEM/lib/SD_Protocols.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 5faad333e..052509e4d 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -6,8 +6,12 @@ # # 2016-2019 S.Butzek, Ralf9 # 2019-2021 S.Butzek, HomeAutoUser, elektron-bbs +# 2022 S.Butzek, HomeAutoUser, elektron-bbs, uwekaditz # ################################################################################ +# 2.07 2022-08-07 uwekaditz +# - CHG: mcBit2SomfyRTS() remove leading '0' in any Somfy telegram if it is not expected +################################################################################ package lib::SD_Protocols; use strict; @@ -16,7 +20,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.06'; +our $VERSION = '2.07'; use Storable qw(dclone); use Scalar::Util qw(blessed); @@ -1085,10 +1089,16 @@ sub mcBit2SomfyRTS { $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData ($mcbitnum)], 4 ); - if ($mcbitnum == 57) { - $bitData = substr($bitData, 1, 56); + # remove leading '0' in any Somfy telegram if it is not expected + if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { + $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } + elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { + $bitData = substr($bitData, 1, $mcbitnum - 1); + $bitData = $bitData . '0'; + $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); + } my $encData = lib::SD_Protocols::binStr2hexStr($bitData); return (1, $encData); From 1dfd6b4540eed1445dac31ec25fd5c4cf300a182 Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Mon, 8 Aug 2022 18:49:37 +0200 Subject: [PATCH 02/12] Comments added --- FHEM/lib/SD_Protocols.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 052509e4d..477c7ca23 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -1091,10 +1091,12 @@ sub mcBit2SomfyRTS { # remove leading '0' in any Somfy telegram if it is not expected if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { + # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { + # length correct but telegram does not start with character 'A' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From 48a6d5d820c452811e66a3e8f92f4b74a828d0bc Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Sun, 14 Aug 2022 14:24:30 +0200 Subject: [PATCH 03/12] telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end --- FHEM/lib/SD_Protocols.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 477c7ca23..a91354d25 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -9,8 +9,10 @@ # 2022 S.Butzek, HomeAutoUser, elektron-bbs, uwekaditz # ################################################################################ +# 2.07 2022-08-14 uwekaditz +# - CHG: mcBit2SomfyRTS() remove leading '0' in Somfy telegram that should start with '8' or 'F' if it is not expected # 2.07 2022-08-07 uwekaditz -# - CHG: mcBit2SomfyRTS() remove leading '0' in any Somfy telegram if it is not expected +# - CHG: mcBit2SomfyRTS() remove leading '0' in Somfy telegram that should start with 'A' if it is not expected ################################################################################ package lib::SD_Protocols; @@ -1095,8 +1097,8 @@ sub mcBit2SomfyRTS { $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } - elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { - # length correct but telegram does not start with character 'A' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111')) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From c5f40146bc00770492857c47e6d758dc1deae181 Mon Sep 17 00:00:00 2001 From: sidey79 <7968127+sidey79@users.noreply.github.com> Date: Sat, 10 Sep 2022 22:08:32 +0200 Subject: [PATCH 04/12] SD_Protocols.pm fix syntax --- FHEM/lib/SD_Protocols.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index a91354d25..40611d015 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -1096,9 +1096,8 @@ sub mcBit2SomfyRTS { # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); - } - elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111')) { - # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + } elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111'))) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From 61383b9b982e7ebd090f87857c6e84f6c537b62b Mon Sep 17 00:00:00 2001 From: sidey79 <7968127+sidey79@users.noreply.github.com> Date: Sun, 11 Sep 2022 18:20:25 +0200 Subject: [PATCH 05/12] 02_mcBit2SomdyRTS.t extended tests reworked code slightly --- FHEM/lib/SD_Protocols.pm | 14 +++++++----- t/SD_Protocols/02_mcBit2SomfyRTS.t | 35 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 40611d015..ea767555a 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -21,6 +21,7 @@ use warnings; use Carp qw(croak carp); use constant HAS_DigestCRC => defined eval { require Digest::CRC; }; use constant HAS_JSON => defined eval { require JSON; }; +use List::Util qw/any/; our $VERSION = '2.07'; use Storable qw(dclone); @@ -1090,17 +1091,18 @@ sub mcBit2SomfyRTS { my $mcbitnum = shift // length $bitData; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData ($mcbitnum)], 4 ); - + + #$self->_logging( qq[lib/mcBit2SomfyRTS, first bit: ]. substr($bitData,0,1), 4 ); + # remove leading '0' in any Somfy telegram if it is not expected if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); - } elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111'))) { - # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 - $bitData = substr($bitData, 1, $mcbitnum - 1); - $bitData = $bitData . '0'; - $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); + } elsif ($mcbitnum == 80 && any { substr($bitData, 0, 5) eq $_ } qw(01010 01000 01111) ) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + $bitData = substr($bitData, 1, $mcbitnum - 1) . q[0]; + $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, remove leading nibble, added last nibble - length: ]. length($bitData), 4 ); } my $encData = lib::SD_Protocols::binStr2hexStr($bitData); diff --git a/t/SD_Protocols/02_mcBit2SomfyRTS.t b/t/SD_Protocols/02_mcBit2SomfyRTS.t index 4a6c4b818..210734fd1 100644 --- a/t/SD_Protocols/02_mcBit2SomfyRTS.t +++ b/t/SD_Protocols/02_mcBit2SomfyRTS.t @@ -6,8 +6,9 @@ use Test2::V0; use lib::SD_Protocols; use Test2::Tools::Compare qw{is}; use Test2::Todo; +use Carp qw(carp); -plan(4); +plan(6); my $id=5043; my ($rcode,$hexresult); @@ -19,6 +20,20 @@ $Protocols->{_protocols}->{5043}{length_min} = 56; $Protocols->{_protocols}->{5043}{length_max} = 57; +sub createCallback { + + return sub { + my $message = shift // carp "message must be provided"; + my $level = shift // 0; + + print qq[ $level (/02_mcBit2SomfyRTS.t/ $message \n]; + }; +}; + + +my $myLocalLogCallback =createCallback(); +$Protocols->registerLogCallback($myLocalLogCallback); + my $target = undef; subtest 'mcbitnum != 57' => sub { @@ -62,3 +77,21 @@ subtest 'message to long' => sub { }; $todo->end; + +subtest 'message Button RC1 up truncate 81 to 80' => sub { + plan(2); + my $bitdata='010100000100000001000001100110100110010001100000101010101100010000000000000100010000'; + + ($rcode,$hexresult)=$Protocols->mcBit2SomfyRTS($target,$bitdata,$id,81); + is($rcode,1,"check returncode for SomfyRTS transmission"); + is($hexresult,'A0808334C8C155880022','check result SomfyRTS'); +}; + +subtest 'message Button RC2 up - length 80' => sub { + plan(2); + my $bitdata='01010101010001001100010110000000000100101001011111011101110001000000000000010001'; + + ($rcode,$hexresult)=$Protocols->mcBit2SomfyRTS($target,$bitdata,$id,80); + is($rcode,1,"check returncode for SomfyRTS transmission"); + is($hexresult,'AA898B00252FBB880022','check result SomfyRTS'); +}; From 8800c48a7561a09ddf495ca1f252c9ea69ab1d31 Mon Sep 17 00:00:00 2001 From: Udo Date: Sun, 20 Nov 2022 16:35:09 +0100 Subject: [PATCH 06/12] Bugfix Bresser protocols 00_SIGNALduino.pm - Frequency changed to 868.3 MHz for all Bresser protocols in documentation. 14_SD_WS.pm - Corrected protocol 115 battery bit, added batChange bit and corrected calculation for negative temperatures. SD_ProtocolData.pm - Changed frequency and register settings for all Bresser protocols to 868.3 MHz. --- FHEM/00_SIGNALduino.pm | 12 ++++++------ FHEM/14_SD_WS.pm | 32 +++++++++++++++++++++----------- FHEM/lib/SD_ProtocolData.pm | 18 ++++++------------ 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/FHEM/00_SIGNALduino.pm b/FHEM/00_SIGNALduino.pm index 9deca76ed..0560c292c 100644 --- a/FHEM/00_SIGNALduino.pm +++ b/FHEM/00_SIGNALduino.pm @@ -4793,14 +4793,14 @@ USB-connected devices (SIGNALduino):
    Example: AVANTEK Wireless Digital Door Bell
  • Bresser_5in1
    - Modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, Packet Length=26 Byte, Frequency 868.35 MHz + Modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, Packet Length=26 Byte, Frequency 868.3 MHz
      Example: BRESSER 5-in-1 weather center, BRESSER rain gauge, Fody E42, Fody E43
  • Bresser_6in1
    - modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, frequency 868.35 MHz + modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, frequency 868.3 MHz
  • Bresser_7in1
    - modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, frequency 868.35 MHz + modulation 2-FSK, Datarate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, frequency 868.3 MHz
  • Fine_Offset_WH51_434
    Modulation 2-FSK, Datarate=17.26 kbps, Sync Word=2DD4, Packet Length=14 Byte, Frequency 433.92 MHz @@ -5375,14 +5375,14 @@ USB-connected devices (SIGNALduino):
      Example: AVANTEK Funk-Türklingel
  • Bresser_5in1
    - Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, Packet Length=26 Byte, Frequenz 868.35 MHz + Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, Packet Length=26 Byte, Frequenz 868.3 MHz
      Beispiel: BRESSER 5-in-1 Wetter Center, BRESSER Profi Regenmesser, Fody E42, Fody E43
  • Bresser_6in1
    - Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, Frequenz 868.35 MHz + Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, FIFO-THR=20 Byte, Frequenz 868.3 MHz
  • Bresser_7in1
    - Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, Frequenz 868.35 MHz + Modulation 2-FSK, Datenrate=8.23 kbps, Sync Word=2DD4, Packet Length=22 Byte, Frequenz 868.3 MHz
  • Fine_Offset_WH51_434
    Modulation 2-FSK, Datenrate=17.26 kbps, Sync Word=2DD4, Packet Length=14 Byte, Frequenz 433.92 MHz diff --git a/FHEM/14_SD_WS.pm b/FHEM/14_SD_WS.pm index cdc3fb8fd..475486df0 100644 --- a/FHEM/14_SD_WS.pm +++ b/FHEM/14_SD_WS.pm @@ -1077,17 +1077,17 @@ sub SD_WS_Parse { # 0123456789012345678901234567890123456789 # ---------------------------------------- # 3DA820B00C1618FFFFFF1808152294FFF01E0000 Msg 1, 40 Nibble from SIGNALduino, T: 15.2 H: 94 G:0 W: 0 D:180 - # CCCCIIIIIIIIFFGGGWWWDDD?TTT?HHVVVXSS Msg 1, 36 Nibble, wind, temperature, humidity, uv + # CCCCIIIIIIIIFFGGGWWWDDD?TTTFHHVVVXSS Msg 1, 36 Nibble, wind, temperature, humidity, uv # CCCCIIIIIIIIFFGGGWWWDDD?RRRRRR???XSS Msg 2, 36 Nibble, wind, rain # C = CRC16 # I = station ID - # F = flags, 4 bit (1: weather station, 2: indoor, 4: soil probe), 1 bit battery (1=ok, 0=low), 3 bit channel + # F = flags, 8 bit (nibble 12 1: weather station, 2: indoor, 4: soil probe, nibble 13 1 bit battery change, 3 bit channel) # G = wind gust in 1/10 m/s, inverted, BCD coded, GGG = FE6 =~ 019 => 1.9 m/s. # W = wind speed in 1/10 m/s, inverted, BCD coded, LSB first nibble, MSB last two nibble, WWW = EFE =~ 101 => 1.1 m/s. # D = wind direction in grad, BCD coded, DDD = 158 => 158 ° # ? = unknown, 0x0, 0x8 or 0xE # T = temperature in 1/10 °C, TTT = 312 => 31.2 °C - # ? = unknown, 0x2, 0x4, 0x6 or 0xF + # F = flags, 4 bit - bit 3 temperature (0=positive, 1=negative), bit 2 ?, bit 1 battery (1=ok, 0=low), bit 0 ? # H = humidity in percent, BCD coded, HH = 23 => 23 % # R = rain counter, inverted, BCD coded # V = uv, inverted, BCD coded @@ -1097,7 +1097,11 @@ sub SD_WS_Parse { model => 'SD_WS_115', prematch => sub { return 1; }, # no precheck known id => sub {my ($rawData,undef) = @_; return substr($rawData,4,8); }, - bat => sub {my (undef,$bitData) = @_; return substr($bitData,52,1) eq '1' ? 'ok' : 'low';}, + bat => sub {my ($rawData,$bitData) = @_; + return if (substr($rawData,12,1) eq '1' && substr($rawData,33,1) eq '1'); # not by weather station & rain + return substr($bitData,110,1) eq '1' ? 'ok' : 'low'; + }, + batChange => sub {my (undef,$bitData) = @_; return substr($bitData,52,1);}, channel => sub {my ($rawData,$bitData) = @_; $channel = ''; $channel = substr($rawData,12,1) if (substr($rawData,12,1) ne '1'); # not weather station @@ -1122,14 +1126,20 @@ sub SD_WS_Parse { $winddir = substr($rawData,20,3); return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]); }, - temp => sub {my ($rawData,undef) = @_; - return if (substr($rawData,33,1) ne '0' || substr($rawData,24,3) !~ m/^\d+$/xms); + temp => sub {my ($rawData,$bitData) = @_; + return if ((substr($rawData,12,1) eq '1' && substr($rawData,33,1) eq '1') || substr($rawData,24,3) !~ m/^\d+$/xms); # not by weather station & rain $rawTemp = substr($rawData,24,3) * 0.1; - if ($rawTemp > 60) {$rawTemp -= 100}; - return $rawTemp; + if (substr($bitData,108,1) eq '1') { + if ($rawTemp > 60) { + $rawTemp -= 100; # Bresser 6in1 + } else { + $rawTemp *= -1; # Bresser 3in1 + } + } + return round($rawTemp,1); }, hum => sub {my ($rawData,undef) = @_; - return if (substr($rawData,33,1) ne '0' || substr($rawData,28,2) !~ m/^\d+$/xms); + return if ((substr($rawData,12,1) eq '1' && substr($rawData,33,1) eq '1') || substr($rawData,28,2) !~ m/^\d+$/xms); # not by weather station & rain $hum = substr($rawData,28,2) * 1; if (substr($rawData,12,1) eq '4' && $hum >= 1 && $hum <= 16) { # Soil Moisture return $moisture_map[$hum - 1]; @@ -1137,14 +1147,14 @@ sub SD_WS_Parse { return $hum; }, rain => sub {my ($rawData,undef) = @_; - return if (substr($rawData,33,1) ne '1' || substr($rawData,12,1) ne '1'); # only weather station + return if (substr($rawData,33,1) ne '1' || substr($rawData,12,1) ne '1'); # message type || weather station $rain = substr($rawData,24,6); $rain =~ tr/0123456789ABCDEF/FEDCBA9876543210/; return if ($rain !~ m/^\d+$/xms); return $rain * 0.1; }, uv => sub {my ($rawData,undef) = @_; - return if (substr($rawData,33,1) ne '0' || substr($rawData,12,1) ne '1'); # only weather station + return if (substr($rawData,33,1) ne '0' || substr($rawData,12,1) ne '1'); # message type || weather station $uv = substr($rawData,30,3); $uv =~ tr/0123456789ABCDEF/FEDCBA9876543210/; return if ($uv !~ m/^\d+$/xms); diff --git a/FHEM/lib/SD_ProtocolData.pm b/FHEM/lib/SD_ProtocolData.pm index 2320b9014..aab468f5f 100644 --- a/FHEM/lib/SD_ProtocolData.pm +++ b/FHEM/lib/SD_ProtocolData.pm @@ -2931,12 +2931,12 @@ package lib::SD_ProtocolData; name => 'Bresser 5in1', comment => 'BRESSER 5-in-1 weather center, rain gauge, Fody E42, Fody E43', id => '108', - knownFreqs => '868.35', + knownFreqs => '868.300', datarate => '8.232', sync => '2DD4', modulation => '2-FSK', rfmode => 'Bresser_5in1', - register => ['0001','022E','0346','042D','05D4','061A','07C0','0800','0D21','0E65','0FE8','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'], + register => ['0001','022E','0346','042D','05D4','061A','07C0','0800','0D21','0E65','0F6A','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'], preamble => 'W108#', clientmodule => 'SD_WS', length_min => '52', @@ -3091,12 +3091,12 @@ package lib::SD_ProtocolData; name => 'Bresser 6in1', comment => 'BRESSER 6-in-1 weather center', id => '115', - knownFreqs => '868.35', + knownFreqs => '868.300', datarate => '8.232', sync => '2DD4', modulation => '2-FSK', rfmode => 'Bresser_6in1', - register => ['0001','022E','0344','042D','05D4','0612','07C0','0800','0D21','0E65','0FE8','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'], + register => ['0001','022E','0344','042D','05D4','0612','07C0','0800','0D21','0E65','0F6A','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'], preamble => 'W115#', clientmodule => 'SD_WS', length_min => '36', @@ -3147,12 +3147,12 @@ package lib::SD_ProtocolData; name => 'Bresser 7in1', comment => 'BRESSER 7-in-1 weather center', id => '117', - knownFreqs => '868.35', + knownFreqs => '868.300', 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'], + register => ['0001','022E','0345','042D','05D4','0616','07C0','0800','0D21','0E65','0F6A','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'], preamble => 'W117#', clientmodule => 'SD_WS', length_min => '44', @@ -3253,12 +3253,6 @@ package lib::SD_ProtocolData; length_min => '23', length_max => '24', }, - - # In Progress: - # "120" => ## Weather station TFA 35.1077.54.S2 with 30.3151 (T/H-transmitter), 30.3152 (rain gauge), 30.3153 (anemometer) - # https://forum.fhem.de/index.php/topic,119335.msg1221926.html#msg1221926 2022-05-17 @ Ronny2510 - # "121" => ## Remote control Busch-Transcontrol HF - Handsender 6861 - "122" => ## TM40, Wireless Grill-, Meat-, Roasting-Thermometer with 4 Temperature Sensors # https://forum.fhem.de/index.php?topic=127938.msg1224516#msg1224516 2022-06-09 @ Prof. Dr. Peter Henning # SD_WS_122_T T: 36 T2: 32 T3: 31 T4: 31 MU;P0=3412;P1=-1029;P2=1043;P3=4706;P4=-2986;P5=549;P6=-1510;P7=-562;D=01212121212121213456575756575756575756565757575656575757575757575657575656575656575757575757575756575756565756565757575757575757565756575757575757575757575757575657565657565757575757575757575757575757575757575756575656565757575621212121212121213456575756;CP=5;R=2;O; From e7d15b3e1575ee397abe26ea2f3ecb77cadee53b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 20 Nov 2022 15:35:55 +0000 Subject: [PATCH 07/12] Automatic updated controls and CHANGED --- controls_signalduino.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controls_signalduino.txt b/controls_signalduino.txt index d9b3d0735..5dfc84e59 100644 --- a/controls_signalduino.txt +++ b/controls_signalduino.txt @@ -1,4 +1,4 @@ -UPD 2022-06-17_18:27:14 235520 FHEM/00_SIGNALduino.pm +UPD 2022-11-20_16:35:09 235514 FHEM/00_SIGNALduino.pm UPD 2021-11-21_21:18:05 17872 FHEM/10_FS10.pm UPD 2020-05-26_11:51:12 20465 FHEM/10_SD_GT.pm UPD 2021-11-28_11:34:02 23375 FHEM/10_SD_Rojaflex.pm @@ -8,11 +8,11 @@ UPD 2022-06-14_08:08:39 20767 FHEM/14_Hideki.pm UPD 2020-10-03_11:48:15 11170 FHEM/14_SD_AS.pm UPD 2021-07-13_20:29:34 29223 FHEM/14_SD_BELL.pm UPD 2022-10-28_16:08:37 182424 FHEM/14_SD_UT.pm -UPD 2022-11-15_21:20:48 134973 FHEM/14_SD_WS.pm +UPD 2022-11-20_16:35:09 135784 FHEM/14_SD_WS.pm UPD 2022-10-24_08:45:52 18704 FHEM/14_SD_WS07.pm UPD 2022-04-15_20:58:20 35384 FHEM/14_SD_WS09.pm UPD 2020-04-13_23:15:56 14325 FHEM/14_SD_WS_Maverick.pm UPD 2021-08-11_21:38:30 37904 FHEM/41_OREGON.pm UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm -UPD 2022-11-15_21:20:48 235908 FHEM/lib/SD_ProtocolData.pm +UPD 2022-11-20_16:35:09 235578 FHEM/lib/SD_ProtocolData.pm UPD 2022-05-31_17:12:21 79342 FHEM/lib/SD_Protocols.pm From 76a93273a775955880831f789211cea6c6861401 Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Sun, 7 Aug 2022 18:19:38 +0200 Subject: [PATCH 08/12] Update SD_Protocols.pm --- FHEM/lib/SD_Protocols.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 5faad333e..052509e4d 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -6,8 +6,12 @@ # # 2016-2019 S.Butzek, Ralf9 # 2019-2021 S.Butzek, HomeAutoUser, elektron-bbs +# 2022 S.Butzek, HomeAutoUser, elektron-bbs, uwekaditz # ################################################################################ +# 2.07 2022-08-07 uwekaditz +# - CHG: mcBit2SomfyRTS() remove leading '0' in any Somfy telegram if it is not expected +################################################################################ package lib::SD_Protocols; use strict; @@ -16,7 +20,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.06'; +our $VERSION = '2.07'; use Storable qw(dclone); use Scalar::Util qw(blessed); @@ -1085,10 +1089,16 @@ sub mcBit2SomfyRTS { $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData ($mcbitnum)], 4 ); - if ($mcbitnum == 57) { - $bitData = substr($bitData, 1, 56); + # remove leading '0' in any Somfy telegram if it is not expected + if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { + $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } + elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { + $bitData = substr($bitData, 1, $mcbitnum - 1); + $bitData = $bitData . '0'; + $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); + } my $encData = lib::SD_Protocols::binStr2hexStr($bitData); return (1, $encData); From 4358ec05092f9e4b2cbfacb98d97bc58589f7789 Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Mon, 8 Aug 2022 18:49:37 +0200 Subject: [PATCH 09/12] Comments added --- FHEM/lib/SD_Protocols.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 052509e4d..477c7ca23 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -1091,10 +1091,12 @@ sub mcBit2SomfyRTS { # remove leading '0' in any Somfy telegram if it is not expected if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { + # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { + # length correct but telegram does not start with character 'A' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From 587881c26aee8cd9bffa2ab9345673594dedc849 Mon Sep 17 00:00:00 2001 From: uwekaditz Date: Sun, 14 Aug 2022 14:24:30 +0200 Subject: [PATCH 10/12] telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end --- FHEM/lib/SD_Protocols.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 477c7ca23..a91354d25 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -9,8 +9,10 @@ # 2022 S.Butzek, HomeAutoUser, elektron-bbs, uwekaditz # ################################################################################ +# 2.07 2022-08-14 uwekaditz +# - CHG: mcBit2SomfyRTS() remove leading '0' in Somfy telegram that should start with '8' or 'F' if it is not expected # 2.07 2022-08-07 uwekaditz -# - CHG: mcBit2SomfyRTS() remove leading '0' in any Somfy telegram if it is not expected +# - CHG: mcBit2SomfyRTS() remove leading '0' in Somfy telegram that should start with 'A' if it is not expected ################################################################################ package lib::SD_Protocols; @@ -1095,8 +1097,8 @@ sub mcBit2SomfyRTS { $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); } - elsif ($mcbitnum == 80 && substr($bitData, 0, 4) eq '0101') { - # length correct but telegram does not start with character 'A' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111')) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From 2d2ffc90b268a2d77e087ea6c8c6a2d5585bd5bb Mon Sep 17 00:00:00 2001 From: sidey79 <7968127+sidey79@users.noreply.github.com> Date: Sat, 10 Sep 2022 22:08:32 +0200 Subject: [PATCH 11/12] SD_Protocols.pm fix syntax --- FHEM/lib/SD_Protocols.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index a91354d25..40611d015 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -1096,9 +1096,8 @@ sub mcBit2SomfyRTS { # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); - } - elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111')) { - # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + } elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111'))) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 $bitData = substr($bitData, 1, $mcbitnum - 1); $bitData = $bitData . '0'; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); From 64a479ef270022f1a07e5b69e8139e54bce439ad Mon Sep 17 00:00:00 2001 From: sidey79 <7968127+sidey79@users.noreply.github.com> Date: Sun, 11 Sep 2022 18:20:25 +0200 Subject: [PATCH 12/12] 02_mcBit2SomdyRTS.t extended tests reworked code slightly --- FHEM/lib/SD_Protocols.pm | 14 +++++++----- t/SD_Protocols/02_mcBit2SomfyRTS.t | 35 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 40611d015..ea767555a 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -21,6 +21,7 @@ use warnings; use Carp qw(croak carp); use constant HAS_DigestCRC => defined eval { require Digest::CRC; }; use constant HAS_JSON => defined eval { require JSON; }; +use List::Util qw/any/; our $VERSION = '2.07'; use Storable qw(dclone); @@ -1090,17 +1091,18 @@ sub mcBit2SomfyRTS { my $mcbitnum = shift // length $bitData; $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData ($mcbitnum)], 4 ); - + + #$self->_logging( qq[lib/mcBit2SomfyRTS, first bit: ]. substr($bitData,0,1), 4 ); + # remove leading '0' in any Somfy telegram if it is not expected if ($mcbitnum == 57 || ($mcbitnum == 81 && substr($bitData,0,1) eq '0')) { # length not correct, byt leading '0' -> remove leading '0' $bitData = substr($bitData, 1, $mcbitnum - 1); $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, truncated to length: ]. length($bitData), 4 ); - } elsif ($mcbitnum == 80 && ((substr($bitData, 0, 5) eq '01010') || (substr($bitData, 0, 5) eq '01000') || (substr($bitData, 0, 5) eq '01111'))) { - # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 - $bitData = substr($bitData, 1, $mcbitnum - 1); - $bitData = $bitData . '0'; - $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, start from Bit1: ]. length($bitData), 4 ); + } elsif ($mcbitnum == 80 && any { substr($bitData, 0, 5) eq $_ } qw(01010 01000 01111) ) { + # length correct but telegram does not start with character 'A', '8' or 'F' , remove leading '0' and add a '0' at the end, see https://forum.fhem.de/index.php/topic,72173.msg1075881.html#msg1075881 + $bitData = substr($bitData, 1, $mcbitnum - 1) . q[0]; + $self->_logging( qq[lib/mcBit2SomfyRTS, bitdata: $bitData, remove leading nibble, added last nibble - length: ]. length($bitData), 4 ); } my $encData = lib::SD_Protocols::binStr2hexStr($bitData); diff --git a/t/SD_Protocols/02_mcBit2SomfyRTS.t b/t/SD_Protocols/02_mcBit2SomfyRTS.t index 4a6c4b818..210734fd1 100644 --- a/t/SD_Protocols/02_mcBit2SomfyRTS.t +++ b/t/SD_Protocols/02_mcBit2SomfyRTS.t @@ -6,8 +6,9 @@ use Test2::V0; use lib::SD_Protocols; use Test2::Tools::Compare qw{is}; use Test2::Todo; +use Carp qw(carp); -plan(4); +plan(6); my $id=5043; my ($rcode,$hexresult); @@ -19,6 +20,20 @@ $Protocols->{_protocols}->{5043}{length_min} = 56; $Protocols->{_protocols}->{5043}{length_max} = 57; +sub createCallback { + + return sub { + my $message = shift // carp "message must be provided"; + my $level = shift // 0; + + print qq[ $level (/02_mcBit2SomfyRTS.t/ $message \n]; + }; +}; + + +my $myLocalLogCallback =createCallback(); +$Protocols->registerLogCallback($myLocalLogCallback); + my $target = undef; subtest 'mcbitnum != 57' => sub { @@ -62,3 +77,21 @@ subtest 'message to long' => sub { }; $todo->end; + +subtest 'message Button RC1 up truncate 81 to 80' => sub { + plan(2); + my $bitdata='010100000100000001000001100110100110010001100000101010101100010000000000000100010000'; + + ($rcode,$hexresult)=$Protocols->mcBit2SomfyRTS($target,$bitdata,$id,81); + is($rcode,1,"check returncode for SomfyRTS transmission"); + is($hexresult,'A0808334C8C155880022','check result SomfyRTS'); +}; + +subtest 'message Button RC2 up - length 80' => sub { + plan(2); + my $bitdata='01010101010001001100010110000000000100101001011111011101110001000000000000010001'; + + ($rcode,$hexresult)=$Protocols->mcBit2SomfyRTS($target,$bitdata,$id,80); + is($rcode,1,"check returncode for SomfyRTS transmission"); + is($hexresult,'AA898B00252FBB880022','check result SomfyRTS'); +};