optional rounding of calibration results #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an option to have calibration results rounded before being sent to SK.
If no decimals are defined, the plugin will work as ever.
See screenshot and test debug ouputs (converting kWh to Ah@12V)
Tests:
config JSON:
decimals entry missing (undefined), legacy: OK (same results as before)
decimals entry empty (NUL): OK (same results as before)
decimals entry valid: OK
2021-05-22T16:31:48.346Z @signalk/calibration path:sensors.PZEM.total sourceRef:mqtt.PZEM decimals: 3 period:
2021-05-22T16:31:48.357Z @signalk/calibration path:sensors.PZEM.today sourceRef:mqtt.PZEM decimals: period:
2021-05-22T16:31:48.358Z @signalk/calibration path:sensors.PZEM.yesterday sourceRef:mqtt.PZEM decimals: undefined period:
...
2021-05-26T10:39:10.548Z @signalk/calibration path:sensors.PZEM.total sourceRef:mqtt.PZEM decimals: 3, period:
2021-05-26T10:39:10.559Z @signalk/calibration path:sensors.PZEM.today sourceRef:mqtt.PZEM decimals: 2, period:
2021-05-26T10:39:10.560Z @signalk/calibration path:sensors.PZEM.yesterday sourceRef:mqtt.PZEM decimals: 1, period:
...
2021-05-26T10:44:16.435Z @signalk/calibration sensors.PZEM.yesterday(mqtt.PZEM) 0.148 => 8.7 (8.693636363636363))
2021-05-26T10:44:17.038Z @signalk/calibration sensors.PZEM.total(mqtt.PZEM) 4.895 => 407.913 (407.91333333333324))
2021-05-26T10:44:45.863Z @signalk/calibration sensors.PZEM.today(mqtt.PZEM) 0.083 => 6.91 (6.9139))
plugin config UI:
decimals entry invalid:
NaN: OK (same results as before)
entry with fraction: entry gets truncated and processed
negative: throws range error exception in SK-log, (garbage in -> garbage out)
`