add offset as meter start value#29463
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugin/getter.go" line_range="37" />
<code_context>
+ offset float64
</code_context>
<issue_to_address>
**issue (bug_risk):** Offset is applied before scaling, which conflicts with the documented offset unit (kWh) and likely leads to incorrect values.
The formula `(f - p.offset) * p.scale` treats `offset` as being in the raw unit of `f`, but the template documents it in kWh (`Zählerstartwert (kWh)`), and `scale` is likely a unit conversion (e.g., Wh → kWh). To apply the offset in kWh, this should be `f*p.scale - p.offset`. If you really intend `offset` to be in raw units, please update the template/help text to match; otherwise, update the computation to `return f*p.scale - p.offset, nil`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
|
|
||
| return f * p.scale, nil | ||
| return (f - p.offset) * p.scale, nil |
There was a problem hiding this comment.
issue (bug_risk): Offset is applied before scaling, which conflicts with the documented offset unit (kWh) and likely leads to incorrect values.
The formula (f - p.offset) * p.scale treats offset as being in the raw unit of f, but the template documents it in kWh (Zählerstartwert (kWh)), and scale is likely a unit conversion (e.g., Wh → kWh). To apply the offset in kWh, this should be f*p.scale - p.offset. If you really intend offset to be in raw units, please update the template/help text to match; otherwise, update the computation to return f*p.scale - p.offset, nil.
|
Which actual problem does this solve? Pls note that per contribution guidelines we prefer an issue before proposing actual changes. |
This PR implements an
offsetvalue for previous customer's meter reading and respects it in combination withscale. It is explicitly not implemented in JQ for reuse with other meters.The
vzloggertemplate is enhanced as an example.