Skip to content

Meter (Home Assistant): support return energy entity#31857

Merged
andig merged 4 commits into
masterfrom
fix/issue-31856
Jul 17, 2026
Merged

Meter (Home Assistant): support return energy entity#31857
andig merged 4 commits into
masterfrom
fix/issue-31856

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

fixes #31856

The homeassistant meter template only exposed a single energy entity, even though its own help text promised it covers both "consumed/produced" energy. There was no way to configure the opposite direction (grid export / battery discharge), because meter/homeassistant.go never decorated the existing api.MeterReturnEnergy capability.

  • Add a returnEnergy param to the homeassistant meter template, rendered as returnenergy:
  • Decode ReturnEnergy in meter/homeassistant.go and decorate implement.MeterReturnEnergy when set, mirroring the existing energy/MeterEnergy handling
  • Clarify the energy/returnEnergy help text to each describe a single direction instead of "consumed/produced"

🤖 Generated with Claude Code

@naltatis
naltatis marked this pull request as ready for review July 17, 2026 06:04
@naltatis
naltatis requested a review from andig July 17, 2026 06:04
@naltatis naltatis added the devices Specific device support label Jul 17, 2026
@naltatis

Copy link
Copy Markdown
Member

LGTM

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've left some high level feedback:

  • Consider guarding the implement.MeterReturnEnergy decorator with a non-empty cc.ReturnEnergy check (mirroring the energy handling) so that a nil returnEnergyG is never passed in and behavior is explicit rather than relying on implement.May to handle nil.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding the `implement.MeterReturnEnergy` decorator with a non-empty `cc.ReturnEnergy` check (mirroring the `energy` handling) so that a nil `returnEnergyG` is never passed in and behavior is explicit rather than relying on `implement.May` to handle nil.

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 commented Jul 17, 2026

Copy link
Copy Markdown
Member

@naltatis könntest Du die Übersetzungen prüfen? Einspeiseenergieentität ist im Allgemeinen Fall immer falsch.

@naltatis

Copy link
Copy Markdown
Member

Update: we use "Gegenrichtung" / "reverse direction" in ui and docs.

@andig
andig merged commit ba27971 into master Jul 17, 2026
9 checks passed
@andig
andig deleted the fix/issue-31856 branch July 17, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Home Assistant meter template: Only one energy entity, no way to configure both consumed/produced energy (grid & battery)

2 participants