Skip to content

Conversation

@premultiply
Copy link
Member

No description provided.

@evcc-bot evcc-bot added devices Specific device support enhancement New feature or request labels Dec 30, 2025
@premultiply premultiply removed the enhancement New feature or request label Dec 30, 2025
@premultiply premultiply marked this pull request as ready for review December 30, 2025 11:42
Copilot AI review requested due to automatic review settings December 30, 2025 11:42
Copy link

Copilot AI left a 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
@premultiply premultiply marked this pull request as draft December 30, 2025 11:48
Copy link
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 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>

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.
@andig andig marked this pull request as ready for review December 30, 2025 11:53
@andig andig enabled auto-merge (squash) December 30, 2025 11:53
Copy link
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 left some high level feedback:

  • 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.
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.

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.
@andig andig merged commit f346644 into master Dec 30, 2025
7 checks passed
@andig andig deleted the fix/mbmd-meters2 branch December 30, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support

4 participants