From 3ffb734571899b0203f937ddd69e392355c8cc48 Mon Sep 17 00:00:00 2001 From: kaihs <> Date: Tue, 18 Dec 2018 19:20:02 +0000 Subject: [PATCH] 36_WMBUS: new attribute ignoreUnknownDataBlocks git-svn-id: https://svn.fhem.de/fhem/trunk@18001 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/36_WMBUS.pm | 13 ++++++++++++- fhem/FHEM/WMBus.pm | 15 ++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index e2341c37d..27dfcada5 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 36_WMBUS: new attribute ignoreUnknownDataBlocks - feature: 49_SSCam: V8.0.0, new type "hls" of streaming devices, hls playback now available for all common browsers, tooltip hints in streaming devices, minor fixes diff --git a/fhem/FHEM/36_WMBUS.pm b/fhem/FHEM/36_WMBUS.pm index c8152e26b..0be5c5d52 100644 --- a/fhem/FHEM/36_WMBUS.pm +++ b/fhem/FHEM/36_WMBUS.pm @@ -33,6 +33,7 @@ sub WMBUS_Initialize($) { " AESkey". " ignore:0,1". " rawmsg_as_reading:0,1". + " ignoreUnknownDataBlocks:0,1". " $readingFnAttributes"; } @@ -333,6 +334,7 @@ sub WMBUS_SetReadings($$$) my $dataBlock; for $dataBlock ( @$dataBlocks ) { + next if AttrVal($name, "ignoreUnknownDataBlocks", 0) && $dataBlock->{type} eq 'MANUFACTURER SPECIFIC'; #WMBus::VIF_TYPE_MANUFACTURER_SPECIFIC readingsBulkUpdate($hash, "$dataBlock->{number}_storage_no", $dataBlock->{storageNo}); readingsBulkUpdate($hash, "$dataBlock->{number}_type", $dataBlock->{type}); readingsBulkUpdate($hash, "$dataBlock->{number}_value", $dataBlock->{value}); @@ -359,7 +361,7 @@ sub WMBUS_SetReadings($$$) } if (AttrVal($name, "rawmsg_as_reading", 0)) { - readingsBulkUpdate($hash, "rawmsg", unpack("H*",$mb->{msg})); + readingsBulkUpdate($hash, "rawmsg", $mb->getFrameType() eq WMBus::FRAME_TYPE_B ? "Y" : "" . unpack("H*",$mb->{msg})); } readingsEndUpdate($hash,1); @@ -526,6 +528,11 @@ WMBUS_Attr(@)
  • rawmsg_as_reading
    If set to 1, received raw messages will be stored in the reading rawmsg. This can be used to log raw messages to help with debugging.
  • +
  • ignoreUnknownDataBlocks
    + If set to 1, datablocks containing unknown/manufacturer specific data will be ignored. This is useful if a meter sends data in different + formats of which some can be interpreted and some not. This prevents the unknown data overwriting the readings of the data that can be + interpreted. +

  • @@ -636,6 +643,10 @@ WMBUS_Attr(@)
  • rawmsg_as_reading
    Wenn auf 1 gesetzt so werden empfangene Nachrichten im Reading rawmsg gespeichert. Das kann verwendet werden um Rohnachrichten zu loggen und beim Debugging zu helfen.
  • +
  • ignoreUnknownDataBlocks
    + Wenn auf 1 gesetzt so werden Datenblocks die unbekannte/herstellerspezifische Daten enthalten ignoriert. Das ist hilfreich wenn ein Zähler Daten in unterschiedlichen + Formaten sendet von denen einige nicht interpretiert werden können. Es verhindert, dass die unbekannten Daten die Readings der interpretierbaren Daten überschreiben. +

  • diff --git a/fhem/FHEM/WMBus.pm b/fhem/FHEM/WMBus.pm index 9780ffd09..a41e07c51 100644 --- a/fhem/FHEM/WMBus.pm +++ b/fhem/FHEM/WMBus.pm @@ -13,7 +13,7 @@ my $hasCTR = ($@)?0:1; require Exporter; my @ISA = qw(Exporter); -my @EXPORT = qw(new parse parseLinkLayer parseApplicationLayer manId2ascii type2string); +my @EXPORT = qw(new parse parseLinkLayer parseApplicationLayer manId2ascii type2string setFrameType getFrameType VIF_TYPE_MANUFACTURER_SPECIFIC); sub manId2ascii($$); @@ -97,10 +97,13 @@ use constant { ERR_CIPHER_NOT_INSTALLED => 16, ERR_LINK_LAYER_INVALID => 17, + VIF_TYPE_MANUFACTURER_SPECIFIC => 'MANUFACTURER SPECIFIC', + # TYPE C transmission uses two different frame types # see http://www.st.com/content/ccc/resource/technical/document/application_note/3f/fb/35/5a/25/4e/41/ba/DM00233038.pdf/files/DM00233038.pdf/jcr:content/translations/en.DM00233038.pdf FRAME_TYPE_A => 'A', FRAME_TYPE_B => 'B', + }; sub valueCalcNumeric($$) { @@ -1175,7 +1178,7 @@ sub decodeValueInformationBlock($$$) { } else { # manufacturer specific data, can't be interpreted - $dataBlockRef->{type} = "MANUFACTURER SPECIFIC"; + $dataBlockRef->{type} = VIF_TYPE_MANUFACTURER_SPECIFIC; $dataBlockRef->{unit} = ""; $analyzeVIF = 0; } @@ -1968,12 +1971,18 @@ sub decodeLinkLayer($$) return 1; } -sub setFrameType($) +sub setFrameType($$) { my $self = shift; $self->{frame_type} = shift; } +sub getFrameType($) +{ + my $self = shift; + return $self->{frame_type}; +} + sub parse($$) { my $self = shift;