Skip to content

optional rounding of calibration results - #8

Open
W-Geronius wants to merge 5 commits into
SignalK:masterfrom
W-Geronius:master
Open

optional rounding of calibration results#8
W-Geronius wants to merge 5 commits into
SignalK:masterfrom
W-Geronius:master

Conversation

@W-Geronius

Copy link
Copy Markdown

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)
CAPT-20210526-124843`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant