Autor Thema: How to ignore specific readings?  (Gelesen 730 mal)

Offline id001

  • New Member
  • *
  • Beiträge: 9
How to ignore specific readings?
« am: 23 März 2021, 16:54:19 »
Hello all! I have a problem and need some help.

I have a modbus to mqtt gateway which sometimes cant read the values correctly from my energy meters and returns "bad" instead of the values. See the attached picture.
The problem is with the statistics module. If at the end of the hour when the statistics are calculated for the last hour the "bad" reading messes up the values and the graphs, too.
How can I ignore this reading?

Thank you.

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 15567
  • "Developer"?!? Meistens doch eher "User"
Antw:How to ignore specific readings?
« Antwort #1 am: 23 März 2021, 17:40:00 »
You're a little spars wrt. to details how readings are generated (no list or RAW definition provided).

If it's always the word "bad", you could try to filter these words out by using some Perl in your readingList attribute.
Based on this from the 6channel_ethernet_board_6input_split attrTemplate:
attr DEVICE readingList Advantech/DEVNAME/data:.* { $EVENT =~ s/true/"on"/g;; $EVENT =~ s/false/"off"/g;; my $rets = json2nameValue($EVENT,'',$JSONMAP);; my %cleaned = map { $_,$rets->{$_} } grep { ReadingsVal($NAME,$_,"unknown") ne $rets->{$_} } keys %{$rets};; return \%cleaned }\I'd suggest sth. like
attr DEVICE readingList <your topic>:.* { my $rets = json2nameValue($EVENT,'',$JSONMAP);; my %cleaned = map { $_,$rets->{$_} } grep { 'bad' ne $rets->{$_} } keys %{$rets};; return \%cleaned }
Server: HP-T620@Debian 10, aktuelles FHEM + ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn:MySensors, Weekday-&RandomTimer, Twilight,  AttrTemplate {u.a. mqtt2, mysensors, zwave}
Gefällt mir Gefällt mir x 1 Liste anzeigen

Offline id001

  • New Member
  • *
  • Beiträge: 9
Antw:How to ignore specific readings?
« Antwort #2 am: 23 März 2021, 19:27:42 »
Thank you, this is what I wanted.