Skip to content

Add power-source selection for hybrid inverter controls#382

Open
tiyash-basu-frequenz wants to merge 1 commit intofrequenz-floss:v0.x.xfrom
tiyash-basu-frequenz:258_hybrid_inverter_controls
Open

Add power-source selection for hybrid inverter controls#382
tiyash-basu-frequenz wants to merge 1 commit intofrequenz-floss:v0.x.xfrom
tiyash-basu-frequenz:258_hybrid_inverter_controls

Conversation

@tiyash-basu-frequenz
Copy link
Contributor

This commit adds the ability to specify a preferred power source when issuing discharge commands to hybrid inverters, which typically have both PV and battery inputs added to them, and can use either of those inputs as the power source.

Both the v1alpha18 and v1alpha19 APIs are updated in this PR. Since v0.19.0 is not yet released, I have renumbered the fields in the SetElectricalComponentPowerRequest message of the v1alpha19 package.

closes #258

This commit adds the ability to specify a preferred power source when
issuing discharge commands to hybrid inverters, which typically have
both PV and battery inputs added to them, and can use either of those
inputs as the power source.

Signed-off-by: Tiyash Basu <tiyash.basu@frequenz.com>
@tiyash-basu-frequenz tiyash-basu-frequenz self-assigned this Mar 3, 2026
@tiyash-basu-frequenz tiyash-basu-frequenz requested a review from a team as a code owner March 3, 2026 15:36
@github-actions github-actions bot added part:docs Affects the documentation part:protobuf Affects the protocol buffer definition files labels Mar 3, 2026
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

Adds a way for clients to express a preferred DC power source when setting discharge active-power setpoints for hybrid inverters, updating both the v1alpha18 and v1alpha19 preview APIs and documenting the additions in release notes.

Changes:

  • Introduce PowerSource enum to express PV/battery preferred/only behaviors for hybrid-inverter discharge commands.
  • Add power_source to SetElectricalComponentPowerRequest (and renumber fields in v1alpha19 as noted in the PR description).
  • Update RELEASE_NOTES.md to reflect v1alpha18 symbol additions and adjust upgrade notes wording.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
proto/frequenz/api/microgrid/v1alpha19/microgrid.proto Adds PowerSource and power_source field; renumbers request fields to accommodate the new field.
proto/frequenz/api/microgrid/v1alpha18/microgrid.proto Adds PowerSource and power_source field as a backward-compatible addition.
RELEASE_NOTES.md Documents the v1alpha18 additions and adjusts upgrade guidance text.
Comments suppressed due to low confidence (6)

proto/frequenz/api/microgrid/v1alpha19/microgrid.proto:605

  • The comment says “discharge power setpoint”, but the rest of this file consistently uses “set-point” (hyphenated). For consistency, consider changing this to “set-point”.
  // The preferred power source for the electrical component when setting a
  // discharge power setpoint. This is relevant for hybrid inverters which have
  // both PV and battery inputs added to them, and can use either of those

proto/frequenz/api/microgrid/v1alpha18/microgrid.proto:616

  • power_source is a proto3 enum field, so callers can’t really “not provide” it in a distinguishable way (omitting it on the wire yields the default POWER_SOURCE_UNSPECIFIED). Consider updating the wording to reflect that POWER_SOURCE_UNSPECIFIED/omitted means PV-preferred, or make the field optional if presence needs to be detected.
  // If the above criteria are met, and this field is not provided, then the API
  // service will default to using `POWER_SOURCE_PV_PREFERRED` as the power
  // source.
  //

proto/frequenz/api/microgrid/v1alpha18/microgrid.proto:605

  • The comment says “discharge power setpoint”, but the rest of this file consistently uses “set-point” (hyphenated). For consistency, consider changing this to “set-point”.
  // The preferred power source for the electrical component when setting a
  // discharge power setpoint. This is relevant for hybrid inverters which have
  // both PV and battery inputs added to them, and can use either of those

proto/frequenz/api/microgrid/v1alpha18/microgrid.proto:620

  • In v1alpha18, power_source is field number 5 but it appears before fields 3 (power) and 4 (request_lifetime) in the message definition. Reordering the fields in the .proto to match numeric order would make the schema easier to read and less error-prone to maintain.
  PowerSource power_source = 5;

RELEASE_NOTES.md:18

  • The release notes summary currently states that all new features are available exclusively in v1alpha19, but this PR also adds new API surface to the stable v1alpha18 package. Please update the earlier summary wording to avoid implying v1alpha18 is unchanged in this release.
## Stable `v1alpha18` Preview API

The `v1alpha18` API is also stable and has the following symbol additions:

proto/frequenz/api/microgrid/v1alpha19/microgrid.proto:616

  • power_source is a proto3 enum field, so callers can’t really “not provide” it in a distinguishable way (omitting it on the wire yields the default POWER_SOURCE_UNSPECIFIED). Consider updating the wording to reflect that POWER_SOURCE_UNSPECIFIED/omitted means PV-preferred, or make the field optional if presence needs to be detected.
  // If the above criteria are met, and this field is not provided, then the API
  // service will default to using `POWER_SOURCE_PV_PREFERRED` as the power
  // source.
  //

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@florian-wagner-frequenz florian-wagner-frequenz left a comment

Choose a reason for hiding this comment

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

LGTM in general, but l don't think we should be doing a breaking update to the Microgrid API without increasing to v1alpha20

POWER_TYPE_REACTIVE = 2;
}

// The preferred power source for an electrical component when issuing a

Choose a reason for hiding this comment

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

Nit: this is not just the preferred power source, as it also allows for "XYZ_ONLY".

// The requested power type.
PowerType power_type = 2;

// The preferred power source for the electrical component when setting a

Choose a reason for hiding this comment

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

Nit: this is not only preferred as it can also be directive.

// is lagging the voltage when viewed from the perspective of the
// electrical component.
float power = 3;
float power = 4;

Choose a reason for hiding this comment

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

I am not sure whether we want to bump the field order. This is a breaking change in my eyes and should correspond to a release of a new alpha version. Otherwise it might be hard to distinguish this from places where nitrogend is running with the "old" v1alpha19 vs. the "new" v1alpha19 (you see what this is doing?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:protobuf Affects the protocol buffer definition files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Specifying DC Energy Source for Hybrid Inverters

3 participants