node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

please remove duplicate value check from node-red-node-pisrf

Open dingausmwald opened this issue 1 year ago • 1 comments

Which node are you reporting an issue on?

node-red-node-pisrf

What are the steps to reproduce?

use it

What happens?

duplicate values are dropped

What do you expect to happen?

every value comes through

Please tell us about your environment:

  • [ 3.0.2] Node-RED version:
  • [ ] node.js version:
  • [ ] npm version:
  • [ ] Platform/OS:
  • [ ] Browser:

pisrf sensors are prone to noise (esp. if there are more present), so error correction is necessary anyway (f.e. with median). This gets difficult if the message count isn't consistent. The duplicate check (duplicate values don't get published) is kind of poor and can be easily implemented with a filter node. On the other hand, a median filter f.e. is difficult when the message count is not predictable.

Just change:

if distance != OLD and distance > 2 and distance < 400: print(distance) OLD = distance

to

if distance > 2 and distance < 400: print(distance)

in node-red-nodes/hardware/PiSrf/nrsrf.py at line 83 to 85 or at least make it an option. I am not familiar with pull requests, otherwise i would submit one.

Thank you

ps: i don't know why the new lines in the code brackets get swallowed, i tried, normally it does work as expected

dingausmwald avatar Mar 01 '23 21:03 dingausmwald

This was/is a deliberate design choice so as not to constantly send a stream of messages to the input which then have to be handled by the node input handler at relatively high frequency on a low powered device. Happy to consider a pull request to make it optional but the default should be as-is so as not to break anyone.

dceejay avatar Mar 09 '23 15:03 dceejay