NodeManager icon indicating copy to clipboard operation
NodeManager copied to clipboard

Bugfix 458 - SensorWaterMeter reports 0 after send

Open fredvik opened this issue 5 years ago • 2 comments

Fix to issue #458 and a new example sketch for a watermeter.

With this fix, _value and _total are not reset after sending for sensors with valueprocessing == SUM. Instead, the total is accumulated inifinitely.

As far as I can tell, only SensorPulseMeter uses this valueprocessing, and its decendants SensorPowerMeter and SensorWaterMeter. The fix is tested for WaterMeter and works fine. Not tested for PowerMeter but I expect it to behave nicely there as well as it should more closely resemble how a physical powermeter behaves. If any (future) sensor needs to summarize only between sends, a new value processing type DELTA can be added that behaves like SUM but is reset in sendValue().

Newbie disclaimer - this is my first pull request :-)

fredvik avatar Apr 26 '19 19:04 fredvik

Thanks for the contribution first of all :-) Let me tell you how I'm using this SensorWaterMeter here (which is not necessarily the best approach) so to find the best compromise. I have a rain gauge and the sensor is reporting to the controller how much rain we had in the last hour. To do this is reports every hour and then clearing the value is needed since the controller cannot make the diff (again not necessarily the way I'm using it here is the best one). Having said that, I believe both the use cases are valid hence having that DELTA additional type you mentioned is probably the way to go so the user can choose which one to use. What do you think?

user2684 avatar May 05 '19 17:05 user2684

Happy if I can be of any help! I certainly agree that both use cases are valid and relevant. The rain meter seems like a useful fit for reporting DELTA-values and I'm sure there are other counting applications where it could be useful as well.

fredvik avatar May 07 '19 20:05 fredvik