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.
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 }
Thank you, this is what I wanted.