FHEM > English Corner

How to ignore specific readings?

(1/1)

id001:
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.

Beta-User:
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:

--- Code: ---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 }\
--- Ende Code ---
I'd suggest sth. like

--- Code: ---attr DEVICE readingList <your topic>:.* { my $rets = json2nameValue($EVENT,'',$JSONMAP);; my %cleaned = map { $_,$rets->{$_} } grep { 'bad' ne $rets->{$_} } keys %{$rets};; return \%cleaned }
--- Ende Code ---

id001:
Thank you, this is what I wanted.

Navigation

[0] Themen-Index

Zur normalen Ansicht wechseln