Skip to content

add offset as meter start value#29463

Open
tolot27 wants to merge 1 commit intoevcc-io:masterfrom
tolot27:meterOffset
Open

add offset as meter start value#29463
tolot27 wants to merge 1 commit intoevcc-io:masterfrom
tolot27:meterOffset

Conversation

@tolot27
Copy link
Copy Markdown
Contributor

@tolot27 tolot27 commented Apr 27, 2026

This PR implements an offset value for previous customer's meter reading and respects it in combination with scale. It is explicitly not implemented in JQ for reuse with other meters.

The vzlogger template is enhanced as an example.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread plugin/getter.go
}

return f * p.scale, nil
return (f - p.offset) * p.scale, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andig
Copy link
Copy Markdown
Member

andig commented Apr 28, 2026

Which actual problem does this solve? Pls note that per contribution guidelines we prefer an issue before proposing actual changes.

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.

2 participants