Skip to content

External control of battery charge power (experimental) #32848

Description

@jeremiahpslewis

Is your feature request related to a problem? Please describe.

The optimizer's load-smoothing recommendations create situations where the home battery should keep charging, but at reduced power — e.g. to flatten grid load peaks or follow a smoothed charging plan. evcc currently offers no way for an external system to express this:

  • The external battery mode API (POST /api/batterymode/{mode}) is all-or-nothing: normal charges at full device power, hold blocks charging entirely. There is no "charge, but at most X W".
  • batterygridchargelimit is a price threshold, not a power cap.

So a HEMS acting on load-smoothing recommendations has to either give up on the smoothing or write to the inverter directly behind evcc's back, which conflicts with evcc's own battery mode register writes.

Describe the solution you'd like

An experimental, external battery charge power limit that mirrors the existing external battery mode API:

  • New optional device capability api.BatteryChargePowerLimiter with SetBatteryChargePowerLimit(power *float64) error; nil releases the limit and restores the device's maximum charge power. Separate from BatteryController, because the limit is orthogonal to mode (a cap can be active while the mode stays normal).
  • POST /api/batterychargepowerlimit/{watts} and DELETE /api/batterychargepowerlimit, plus an MQTT setter batteryChargePowerLimit. Runtime only, never persisted.
  • The same 60 s refresh-or-revert watchdog as the external battery mode: if the external controller stops refreshing, evcc restores the device maximum. Release on shutdown, and a forced write on the first update cycle so device state is known after a restart.
  • Custom meters implement it via a limitchargepower setter plugin; the value stays in watts and is clamped to [0, maxchargepower] (with maxchargepower required). Device templates (e.g. Fronius GEN24 via sunspec model 124 InWRte) can then wire it up in follow-ups.

Describe alternatives you've considered

  • Battery mode hold pulses: duty-cycling hold/normal to approximate a power cap — imprecise, chatty on the inverter registers, and fights the mode watchdog.
  • Device-side revert timers (e.g. sunspec InOutWRte_RvrtTms) instead of an evcc-side watchdog: a device-side revert would also undo evcc's own hold/charge writes, which are change-triggered rather than refreshed. The evcc-side watchdog matches the existing battery mode design.
  • Direct Modbus writes from the HEMS: conflicts with evcc's register ownership (StorCtl_Mod is written by mode changes) and bypasses evcc's state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requeststaleOutdated and ready to close

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions