evcc icon indicating copy to clipboard operation
evcc copied to clipboard

FR add getmaxpower / getmaxcurrent to HEMS

Open SolarPower2024 opened this issue 4 months ago • 7 comments

At the moment for configuration a custom external limitation there is a need to define a fixed number as limit. Can getmaxpower and getmaxcurrent be added there, so that the limit can be be provided by an external logic, e.g. via mqtt or http source?

e.g.

type: relay
getmaxpower:
  source: http
  uri: http://192.168.1.50/api/states/xyz
  method: GET
  headers:
.......
limit: # input signal, plugin
  source: const
  value: false

SolarPower2024 avatar Jul 26 '26 21:07 SolarPower2024

This looks like it maps to the relay HEMS integration in hems/relay/relay.go.

Currently NewFromConfig reads:

cc := struct {
    MaxPower    float64
    Limit       plugin.Config
    Passthrough *plugin.Config
    Interval    time.Duration
}{...}

Limit is already a plugin.Config (so it can be sourced from mqtt/http/etc., as in your example), but MaxPower is a fixed float64 set once at startup and never re-read (hems/relay/relay.go:33, :40, :63, :77). There's no MaxCurrent concept in this HEMS integration at all — it only exposes MaxConsumptionPower() (watts) via api.HEMS, not a current-based limit, so getmaxcurrent wouldn't apply here directly.

Turning MaxPower into a dynamic getter (e.g. a plugin.Config-based GetMaxPower, polled each run() cycle alongside the relay state) looks feasible, but it changes existing config semantics and needs a decision on backward compatibility with the current fixed maxPower field, plus error handling if the getter fails at runtime. That's more of a small design/enhancement than an obvious one-line fix, so I'm not opening a PR for it — flagging as an enhancement for maintainer input.

🤖 Generated with Claude Code

github-actions[bot] avatar Jul 26 '26 21:07 github-actions[bot]

Sounds to me like a fully custom HEMS could be a solution? Incidentally, this is missing today. It would be nice to postpone implementation until the failsafe semantics have been clarified.

andig avatar Jul 27 '26 08:07 andig

Thanks, yes a custom hems would be a solution. If at some point of time it can be implemented, would be great :)

SolarPower2024 avatar Jul 27 '26 08:07 SolarPower2024

Already done, please give it a try. Can add build if required.

andig avatar Jul 27 '26 08:07 andig

At the moment for configuration a custom external limitation there is a need to define a fixed number as limit.

Revisiting this. Instead of configuring a HEMS you can already configure GetMaxPower on the root circuit. The circuit will already take the minimum of HEMS and circuit limit.

andig avatar Jul 27 '26 11:07 andig

For circuit it's working already yes. But I'd like to prefer it in hems, if there is nothing against it to make a custom one there as well.

Reason behind: I like the option to download the info when the limit is active - that's only working in hems, not in a standard circuit.

As I never made a build myself, may I ask you to bring it to nightly and I test it? Otherwise I will try to check how building works (for no-developer not that clear 😅)

SolarPower2024 avatar Jul 27 '26 11:07 SolarPower2024

Test binaries for the fix in #32187 are ready to test:

github-actions[bot] avatar Jul 27 '26 11:07 github-actions[bot]