Skip to content

Commit

Permalink
WMBUS extension to dispatch messages (#1252)
Browse files Browse the repository at this point in the history
* WMBUS proposal - extension to dispatch messages
* feat[00_SIGNALduino]: Changed input validation for WMBus
* fix[00_SIGNALduino]: Removed unneded code
* fix[00_SIGNALduino]: Syntax
* build[updateversion]: Allow codecov/patch check to be failed
* Update Versiondate
  • Loading branch information
HomeAutoUser committed Apr 25, 2024
1 parent 664ac52 commit f814e4f
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 58 deletions.
1 change: 1 addition & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 20
allowed-conclusions: success,skipped,cancelled,neutral
ignore-checks: codecov/patch

- name: git push
if: ${{ steps.commit.outputs.status }}
Expand Down
37 changes: 28 additions & 9 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 00_SIGNALduino.pm 3.5.6 2024-03-09 15:50:25Z sidey79 $
# $Id: 00_SIGNALduino.pm 3.5.6 2024-04-24 06:21:19Z HomeAutoUser $
# v3.5.6 - 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 @@ -42,7 +42,7 @@ use List::Util qw(first);


use constant {
SDUINO_VERSION => '3.5.6+20231214', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_VERSION => '3.5.6+20240410', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
Expand Down Expand Up @@ -232,6 +232,7 @@ my $clientsSIGNALduino = ':CUL_EM:'
.'SD_WS:'
.'SD_WS_Maverick:'
.'SOMFY:'
.'WMBUS:'
.' :' # Zeilenumbruch
.'Siro:'
.'SIGNALduino_un:'
Expand Down Expand Up @@ -271,6 +272,7 @@ my %matchListSIGNALduino = (
'31:KOPP_FC' => '^kr\w{18,}',
'32:PCA301' => '^\\S+\\s+24',
'33:SD_Rojaflex' => '^P109#[A-Fa-f0-9]+',
'34:WMBUS' => '^b.*',
'X:SIGNALduino_un' => '^[u]\d+#.*',
);

Expand Down Expand Up @@ -2170,7 +2172,7 @@ sub SIGNALduino_Split_Message {
$patternList{$pattern[0]} = $pattern[1];
$hash->{debugMethod}->(qq[$name: extracted pattern @pattern \n]);
}
elsif($_ =~ m/D=\d+/ or $_ =~ m/^D=[A-F0-9]+/) #### Message from array
elsif($_ =~ m/D=\d+/ or $_ =~ m/^D=Y?[A-F0-9]+/) #### Message from array
{
$_ =~ s/D=//;
$rawData = $_ ;
Expand Down Expand Up @@ -2904,17 +2906,18 @@ sub SIGNALduino_Parse_MN {

my $hash = shift // return; #return if no hash is provided
my $rmsg = shift // return; #return if no rmsg is provided

if ($rmsg !~ /^MN;D=[0-9A-F]+;(?:R=[0-9]+;)?(?:A=-?[0-9]{1,3};)?$/) { # AFC cc1101 0x32 (0xF2): FREQEST – Frequency Offset Estimate from Demodulator


# Verify if rmsg has the correct values:
if ($rmsg !~ /^MN;D=Y?[0-9A-F]+;(?:R=[0-9]+;)?(?:A=-?[0-9]{1,3};)?$/) { # AFC cc1101 0x32 (0xF2): FREQEST – Frequency Offset Estimate from Demodulator
$hash->{logMethod}->($hash->{NAME}, 3, qq[$hash->{NAME}: Parse_MN, faulty msg: $rmsg]);
return ; # Abort here if not successfull
}

# Extract Data from rmsg:
my %msg_parts = SIGNALduino_Split_Message($rmsg, $hash->{NAME});

# Verify if extracted hash has the correct values:
my $rawData = _limit_to_hex($msg_parts{rawData}) // $hash->{logMethod}->($hash->{NAME}, 3, qq[$hash->{NAME}: Parse_MN, faulty rawData D=: $msg_parts{rawData}]) // return ;

my $rawData = (substr $msg_parts{rawData},0,1 eq q[Y]) ? substr($msg_parts{rawData},1) : $msg_parts{rawData};
my $rssi;
my $rssiStr= '';
my $freqafc;
Expand Down Expand Up @@ -3419,7 +3422,7 @@ sub SIGNALduino_IdList {
push (@skippedWhiteId, $id);
next;
}
my $clientmodule = $hash->{protocolObject}->getProperty($id,'clientmodule',undef);
my $clientmodule = $hash->{protocolObject}->getProperty($id,'clientmodule',undef);
$hash->{Clients} .= qq[$clientmodule:] if (defined $clientmodule && $hash->{Clients} !~ /$clientmodule:/); # add module only if clientModule is known and don't do it more than once
} else { # whitelist not active
if (exists($BlacklistIDs{$id})) {
Expand Down Expand Up @@ -4876,6 +4879,14 @@ USB-connected devices (SIGNALduino):<br>
<li>SlowRF<br>
modulation ASK/OOK, <b>loads the standard setting from the uC</b>
</li>
<li>WMBus_S<br>
modulation FSK, Datarate=32.768 kbps, Sync Word=7696, frequency 868.300 MHz (processing needs to be integrated into firmware)
<ul><small>example: water, gas, heat, electric meters and the data collecting devices</small></ul>
</li>
<li>WMBus_T<br>
modulation FSK, Datarate=100.0 kbps, Sync Word=543D, frequency 868.950 MHz (processing needs to be integrated into firmware)
<ul><small>example: water, gas, heat, electric meters and the data collecting devices</small></ul>
</li>
</ul>
</li><br>
<a name="suppressDeviceRawmsg"></a>
Expand Down Expand Up @@ -5483,6 +5494,14 @@ USB-connected devices (SIGNALduino):<br>
<li>SlowRF<br>
Modulation ASK/OOK, <b>l&auml;d die Standard Einstellung vom uC</b>
</li>
<li>WMBus_S<br>
Modulation FSK, Datenrate=32.768 kbps, Sync Word=7696, Frequenz 868.300 MHz (Verarbeitung muss noch in Firmware integriert werden)
<ul><small>Beispiel: diverse Wasser-, Gas-, Wärme- und Stromzähler sowie die Datenerfassungsgeräte</small></ul>
</li>
<li>WMBus_T<br>
Modulation FSK, Datenrate=100.0 kbps, Sync Word=543D, Frequenz 868.950 MHz (Verarbeitung muss noch in Firmware integriert werden)
<ul><small>Beispiel: diverse Wasser-, Gas-, Wärme- und Stromzähler sowie die Datenerfassungsgeräte</small></ul>
</li>
</ul>
</li><br>
<a name="suppressDeviceRawmsg"></a>
Expand Down
96 changes: 50 additions & 46 deletions FHEM/lib/SD_ProtocolData.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: SD_ProtocolData.pm 26975 2024-01-06 16:07:53Z elektron-bbs $
# $Id: SD_ProtocolData.pm 26975 2024-04-24 06:21:19Z HomeAutoUser $
# The file is part of the SIGNALduino project.
# All protocol definitions are contained in this file.
#
Expand Down Expand Up @@ -2940,6 +2940,7 @@ package lib::SD_ProtocolData;
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_5in1',
regexMatch => qr/^[a-fA-F0-9]/,
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',
Expand Down Expand Up @@ -3100,6 +3101,7 @@ package lib::SD_ProtocolData;
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_6in1',
regexMatch => qr/^[a-fA-F0-9]/,
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',
Expand Down Expand Up @@ -3159,6 +3161,7 @@ package lib::SD_ProtocolData;
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_7in1',
regexMatch => qr/^[a-fA-F0-9]/,
register => ['0001','022E','0345','042D','05D4','0617','07C0','0800','0D21','0E65','0F6A','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'],
preamble => 'W117#',
clientmodule => 'SD_WS',
Expand Down Expand Up @@ -3485,6 +3488,7 @@ package lib::SD_ProtocolData;
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_lightning',
regexMatch => qr/^[a-fA-F0-9]/,
register => ['0001','022E','0342','042D','05D4','060A','07C0','0800','0D21','0E65','0F6A','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'],
preamble => 'W131#',
clientmodule => 'SD_WS',
Expand Down Expand Up @@ -3522,6 +3526,51 @@ package lib::SD_ProtocolData;
length_min => '24',
length_max => '24',
},
"133" => # WMBus_S
# https://wiki.fhem.de/wiki/WMBUS
# note !!! Implementation in the FW still needs to be done, register settings are not sufficient
# - definition is in advance in order to dispatch a DMSG | https://github.com/RFD-FHEM/RFFHEM/issues/1247
{
name => 'WMBus_S',
comment => 'WMBus mode S',
id => '133',
knownFreqs => '868.300',
datarate => '32.720',
preamble => 'b',
modulation => '2-FSK',
rfmode => 'WMBus_S',
# registers need to be adjusted and can be optimized if necessary
register => ['0006','012E','0200','0300','0476','0596','06FF','0704','0802','0900','0A00','0B08','0C00','0D21','0E65','0F6A','106A','114A','1206','1322','14F8','1547','1607','1700','1818','192E','1A6D','1B04','1C09','1DB2','1E87','1F6B','20F8','21B6','2210','23EF','242A','2512','261F','2741'],
length_min => '56', # to filter messages | must check
clientmodule => 'WMBUS',
#regexMatch => qr/^b/, # ToDo, check! fuer eine regexp Pruefung am Anfang vor dem method Aufruf
},
"134" => # WMBus_T
# https://wiki.fhem.de/wiki/WMBUS
# note !!! Implementation in the FW still needs to be done, register settings are not sufficient
# - definition is in advance in order to dispatch a DMSG | https://github.com/RFD-FHEM/RFFHEM/issues/1247
# messages with normal identifier
# RAWMSG: MN;D=3E44FA1213871122011633057A1C002025417CD28E06770269857D8001EF3B8BBE56BA7E06855CBA0334149F51682F2E6E2960E6900F800C0001090086B41E003A6F140131414D7D88810A;R=10;A=16;
# DMSG: b3E44FA1213871122011633057A1C002025417CD28E06770269857D8001EF3B8BBE56BA7E06855CBA0334149F51682F2E6E2960E6900F800C0001090086B41E003A6F140131414D7D88810A
# messages with Y identifier
# RAWMSG: MN;D=Y304497264202231800087A3E0020A5EE5B2074920E46E4B4A26B99C92C8DD3A55F44FAF6AE0256B354F9C48C717BFAD43400FB;R=251;A=0;
# DMSG: bY304497264202231800087A3E0020A5EE5B2074920E46E4B4A26B99C92C8DD3A55F44FAF6AE0256B354F9C48C717BFAD43400FB
{
name => 'WMBus_T',
comment => 'WMBus mode C and T',
id => '134',
knownFreqs => '868.950',
datarate => '100.000',
preamble => 'b',
modulation => '2-FSK',
rfmode => 'WMBus_T',
# registers need to be adjusted and can be optimized if necessary
register => ['0006','012E','0200','0300','0454','053D','06FF','0704','0802','0900','0A00','0B08','0C00','0D21','0E6B','0FD0','105C','1104','1206','1322','14F8','1544','1607','1700','1818','192E','1ABF','1B43','1C09','1DB5','1E87','1F6B','20F8','21B6','2210','23EF','242A','2513','261F','2741'],
length_min => '56', # to filter messages | must check
clientmodule => 'WMBUS',
#regexMatch => qr/^b/, # ToDo, check! fuer eine regexp Pruefung am Anfang vor dem method Aufruf
},

########################################################################
#### ### register informations from other hardware protocols #### ####

Expand Down Expand Up @@ -3583,51 +3632,6 @@ package lib::SD_ProtocolData;
# rfmode => 'RIO',
# register => ['000D','012E','022D','0347','04D3','0591','063D','0704','0832','0900','0A00','0B06','0C00','0D21','0E65','0F6F','1086','1190','1218','1323','14B9','1540','1607','1700','1818','1914','1A6C','1B07','1C00','1D91','1E87','1F6B','20F8','21B6','2211','23EF','240D','253E','261F','2741'],
# },
# "997" => # WMBus_C
# # https://wiki.fhem.de/wiki/WMBUS
# # settings from CUL
# {
# name => 'WMBus_C',
# comment => '',
# id => '997',
# developId => 'm',
# knownFreqs => '',
# datarate => '',
# modulation => '2-FSK',
# rfmode => 'WMBus_C',
# register => ['0029','012E','023F','0307','04D3','0591','06FF','0704','0845','0900','0A00','0B0F','0C00','0D1E','0EC4','0FEC','108C','1122','1202','1322','14F8','1547','1607','1730','1804','1976','1A6C','1B03','1C40','1D91','1E87','1F6B','20F8','2156','2210','23A9','240A','2520','260D','2741'],
# #regexMatch => qr/^9/, # ToDo, check! fuer eine regexp Pruefung am Anfang vor dem method Aufruf
# },
# "998" => # WMBus_S
# # https://wiki.fhem.de/wiki/WMBUS
# # settings from CUL
# {
# name => 'WMBus_S',
# comment => '',
# id => '998',
# developId => 'm',
# knownFreqs => '',
# datarate => '',
# modulation => '2-FSK',
# rfmode => 'WMBus_S',
# register => ['0006','012E','0200','0300','0476','0596','06FF','0704','0802','0900','0A00','0B08','0C00','0D21','0E65','0F6A','106A','114A','1206','1322','14F8','1547','1607','1700','1818','192E','1A6D','1B04','1C09','1DB2','1E87','1F6B','20F8','21B6','2210','23EF','242A','2512','261F','2741'],
# #regexMatch => qr/^9/, # ToDo, check! fuer eine regexp Pruefung am Anfang vor dem method Aufruf
# },
# "999" => # WMBus_T
# # https://wiki.fhem.de/wiki/WMBUS
# # settings from CUL
# {
# name => 'WMBus_T',
# comment => '',
# id => '999',
# developId => 'm',
# knownFreqs => '',
# datarate => '',
# modulation => '2-FSK',
# rfmode => 'WMBus_T',
# register => ['0006','012E','0200','0300','0454','053D','06FF','0704','0802','0900','0A00','0B08','0C00','0D21','0E6B','0FD0','105C','1104','1206','1322','14F8','1544','1607','1700','1818','192E','1ABF','1B43','1C09','1DB5','1E87','1F6B','20F8','21B6','2210','23EF','242A','2513','261F','2741'],
# #regexMatch => qr/^9/, # ToDo, check! fuer eine regexp Pruefung am Anfang vor dem method Aufruf
# },

########################################################################
#### ### old information from incomplete implemented protocols #### ####
Expand Down
4 changes: 2 additions & 2 deletions controls_signalduino.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UPD 2024-03-09_15:50:57 240692 FHEM/00_SIGNALduino.pm
UPD 2024-04-24_08:10:04 241827 FHEM/00_SIGNALduino.pm
UPD 2023-01-06_12:08:43 20082 FHEM/10_FS10.pm
UPD 2024-01-03_23:05:39 27250 FHEM/10_SD_GT.pm
UPD 2023-01-01_18:10:40 25403 FHEM/10_SD_Rojaflex.pm
Expand All @@ -14,5 +14,5 @@ UPD 2023-01-23_21:06:26 38569 FHEM/14_SD_WS09.pm
UPD 2023-01-09_19:54:48 16458 FHEM/14_SD_WS_Maverick.pm
UPD 2023-01-28_20:08:00 40378 FHEM/41_OREGON.pm
UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm
UPD 2024-01-06_20:21:35 252437 FHEM/lib/SD_ProtocolData.pm
UPD 2024-04-22_21:14:37 253287 FHEM/lib/SD_ProtocolData.pm
UPD 2024-01-06_20:21:35 81862 FHEM/lib/SD_Protocols.pm
34 changes: 33 additions & 1 deletion t/FHEM/00_SIGNALduino/01_SIGNALduino_Parse_MN.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ my @mockData = (
plan => 2,
testname => q[Good MN data, without RSSI, with set attribute rfmode=PCA301],
input => q[MN;D=0405019E8700AAAAAAAA0F13AA16ACC0540AAA49C814473A2774D208AC0B0167;R=6;],
rValue => 1,
rValue => 3,
rfmode => 'PCA301'
},
{
Expand Down Expand Up @@ -140,6 +140,38 @@ my @mockData = (
rValue => 1,
rfmode => 'Bresser_6in1'
},
{
deviceName => q[dummyDuino],
plan => 2,
testname => q[Good MN data, with RSSI, with set attribute rfmode=WMBus_T, Medium OMS MUC, DMSG started with b],
input => q[MN;D=2547F536721602000231D27C7A000008000F80130001090086B41E00175914011B0806020400000000001945000E;R=14;A=0;],
rValue => 2,
rfmode => 'WMBus_T'
},
{
deviceName => q[dummyDuino],
plan => 2,
testname => q[Good MN data, with RSSI, with set attribute rfmode=WMBus_T, Medium Heat Cost Allocator, DMSG started with b],
input => q[MN;D=3E44F53611275600010884B57AA9002025D27FDD54048072F9A9D06C2E2E5249A41E363DE1F27AF3DE4DD325507C67A9E33CDDC4A70F800C0001090086B41E0063B414011E070416C500FC;R=252;A=0;],
rValue => 2,
rfmode => 'WMBus_T'
},
{
deviceName => q[dummyDuino],
plan => 2,
testname => q[Good MN data, with RSSI, with set attribute rfmode=WMBus_T, Medium Cold water, DMSG started with bY],
input => q[MN;D=Y25442D2C769390751B168D20955084E7204D4874442AA58272A51FCE1430C0A769C3BEF95A2096D1;R=209;A=-6;],
rValue => 2,
rfmode => 'WMBus_T'
},
{
deviceName => q[dummyDuino],
plan => 2,
testname => q[Good MN data, with RSSI, with set attribute rfmode=WMBus_T, Medium Heat Cost Allocator, DMSG started with bY],
input => q[MN;D=Y304497264202231800087A2A0020A53848C8EA9DD3055EA724A2E2AE04E995205589AADC82F6305A620959E6424F406B3B00F6;R=246;A=0;],
rValue => 2,
rfmode => 'WMBus_T'
},
);


Expand Down

0 comments on commit f814e4f

Please sign in to comment.