-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MBMD: fix & simplify meter templates #26257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to simplify meter template conditionals by converting multi-line if-else blocks into more concise inline conditional expressions. The changes affect three MBMD meter templates for ORNO and DDM devices.
Key Changes:
- Simplified conditional power field assignment from multi-line if-else blocks to inline template expressions
- For orno-we514_515 and orno-we504: Consolidated identical energy field values (both branches used "Sum")
- For ddm-18sd: Changed energy field from conditional Import/Export to always use Sum
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| templates/definition/meter/orno-we514_515.yaml | Refactored power field conditional to inline syntax; consolidated energy field (was always "Sum" in both branches) |
| templates/definition/meter/orno-we504.yaml | Refactored power field conditional to inline syntax; consolidated energy field (was always "Sum" in both branches) |
| templates/definition/meter/ddm-18sd.yaml | Refactored power field conditional to inline syntax; changed energy field from conditional Import/Export to always use Sum |
There was a problem hiding this 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 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `templates/definition/meter/ddm-18sd.yaml:15` </location>
<code_context>
- power: -Power
- energy: Export
- {{- end }}
+ power: {{- if eq .usage "pv" }}-{{- end }}Power
+ energy: Sum
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `{{-` here likely removes the space after `power:` and produces `power:-Power`, which is invalid/undesired YAML.
Because `{{-` trims the preceding space, this will render as `power:-Power`/`power:Power` instead of `power: -Power`/`power: Power`, which may produce invalid YAML or break consumers that rely on a space after `:`. Consider dropping the dash on the opening tag (`power: {{ if eq .usage "pv" }}-{{ end }}Power`) or otherwise ensuring a space is preserved in the rendered YAML.
</issue_to_address>
### Comment 2
<location> `templates/definition/meter/orno-we504.yaml:15` </location>
<code_context>
- power: -Power
- energy: Export
- {{- end }}
+ power: {{- if eq .usage "pv" }}-{{- end }}Power
+ energy: Sum
</code_context>
<issue_to_address>
**issue (bug_risk):** Same whitespace-trimming issue: `{{-` likely yields `power:-Power` or `power:Power` instead of keeping a space after the colon.
Because `{{-` removes the preceding space, this will output `power:-Power`/`power:Power`, which is invalid YAML and inconsistent with the previous format. Please avoid trimming the left whitespace here or explicitly include a space in the template to preserve `power: -Power`.
</issue_to_address>
### Comment 3
<location> `templates/definition/meter/orno-we514_515.yaml:18` </location>
<code_context>
- power: -Power
- energy: Export
- {{- end }}
+ power: {{- if eq .usage "pv" }}-{{- end }}Power
+ energy: Sum
</code_context>
<issue_to_address>
**issue (bug_risk):** Whitespace trimming around the template action likely changes `power: -Power` into `power:-Power`, which may break YAML parsing.
Because `{{-` trims the space after `power:`, this will render as `power:-Power`, which is invalid YAML. Please keep a space between the colon and the value (e.g. adjust the delimiters or add an explicit space) so the generated YAML remains valid for all meter templates.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- In
ddm-18sd.yamltheenergyfield changes fromImport/Exportbased on.usageto alwaysSum; if this is intentional, consider adding a brief code comment or commit note because it’s a behavioral change compared to the other meters that still useSumonly for non‑PV.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ddm-18sd.yaml` the `energy` field changes from `Import`/`Export` based on `.usage` to always `Sum`; if this is intentional, consider adding a brief code comment or commit note because it’s a behavioral change compared to the other meters that still use `Sum` only for non‑PV.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
No description provided.