marstek-venus-rs485-node-red icon indicating copy to clipboard operation
marstek-venus-rs485-node-red copied to clipboard

[Improvement] Extend import/export peak-shaving logic to support per-phase peak shaving

Open nickles-lee opened this issue 8 months ago • 3 comments

Summary

Currently peak shaving is based on the aggregate P1/grid value only.

That works for limiting overall import from the grid, but it does not protect against a single phase exceeding its fuse. In a 3-phase installation, the aggregate can still look acceptable while one individual phase is severely overloaded.

This improvement is to extend the existing peak-shaving logic so it can also perform per-phase peak shaving when per-phase sensors are available.

Scope

This issue is specifically about the existing peak-shaving behavior around:

  • Limit power from grid
  • Enable import peak shaving
  • (and the corresponding export shaving, less likely to be an issue)

If Phase 1 / Phase 2 / Phase 3 sensors are configured, and per-phase peak shaving is enabled, the controller should also consider the load on each individual phase and shave peaks that exceed the configured per-phase safety rating.

A common case in the Netherlands is a 25A per-phase connection, so this is mainly about preventing a single phase from exceeding that limit even when total grid import is still within the aggregate target.

Requested functionality

Add an optional mode that extends import peak shaving from:

  • aggregate-only peak shaving

to:

  • aggregate peak shaving plus
  • per-phase peak shaving

Expected behavior

When all of the following are true:

  • Enable import peak shaving is enabled
  • per-phase sensors are provided
  • per-phase peak shaving is enabled

then the strategy should:

  1. Continue respecting the existing aggregate Limit power from grid
  2. Also monitor L1 / L2 / L3 individually
  3. Increase battery discharge (or throttle charging) when needed to keep any individual phase below its configured maximum
  4. Base the control decision on the individual phases, not just the aggregate total & apply logic to batteries known to operate on the phase that needs shaving

In other words: if one phase is above its allowed threshold, the controller should react even if the aggregate import is still below the current grid limit.

Proposed configuration

This likely builds on the earlier per-phase sensor/config work and should remain fully backward compatible.

Suggested additions:

  • Enable per-phase peak shaving: false by default
  • Reuse the configured max power per phase threshold (see https://github.com/gitcodebob/marstek-venus-rs485-node-red/issues/100?reload=1)
  • Only activate per-phase logic when phase sensors are present and batteries are assigned to phases

Control logic suggestion

At a high level, the controller could determine the required battery response as the maximum of:

  • discharge/throttling needed to stay below the aggregate Limit power from grid
  • discharge/throttling needed to keep Phase 1 below max power per phase
  • discharge/throttling needed to keep Phase 2 below max power per phase
  • discharge/throttling needed to keep Phase 3 below max power per phase

That way:

  • aggregate protection still works as today
  • per-phase protection becomes an additional constraint
  • the battery responds to whichever limit is violated first

Why this matters

Aggregate-only shaving is economically useful, but it is not enough for electrical protection in a 3-phase setup.

Per-phase shaving would help with:

  • avoiding overload on a single phase
  • better support for uneven household loads across phases
  • safer use in homes with a common 25A per-phase limit
  • laying the groundwork for more advanced phase-aware control later

Backward compatibility

This should not change behavior for existing users unless they explicitly configure per-phase sensors and enable the feature.

Expected compatibility behavior:

  • no phase sensors configured → current aggregate-only behavior remains unchanged
  • phase sensors configured but feature disabled → current behavior remains unchanged
  • phase sensors configured and feature enabled → aggregate + per-phase shaving becomes active

Possible acceptance criteria

  • Existing aggregate import peak shaving continues to behave as it does today
  • Per-phase peak shaving can be enabled independently
  • Per-phase logic is only active when L1 / L2 / L3 sensors are available
  • Controller reacts when any single phase exceeds the configured max power per phase
  • Controller still respects aggregate Limit power from grid
  • Effective battery power request is based on the most restrictive constraint
  • No regressions for single-phase or aggregate-only setups

nickles-lee avatar Mar 16 '26 11:03 nickles-lee

I would like this to be implemented.

I have sometimes to watch/limit my power draw. In my case when:

  • the batteries are not yet fully charged
  • I have a large power user on phase 3 (EV)
  • my PV installation is producing max power
  • the battery on phase 3 is "selected" as active battery (Cycle which battery to charge first)
Image

Because HBC is controlling for "self-consumption" it is charging the battery on phase 3 at maximum power.

EV charger (3.7kW) and battery (2.5kW) gives together 6.2 kW. This is more than my 5.7 kW per phase connection (3x25A ). It could trip the main breaker.

One remark: Do not use the individual power (watt) phase sensors, but use the current (amperage) phase sensors. After all, the circuit breakers trip on too much current. Power can fluctuate because the voltage fluctuates, I have most of the time more than 230V (varies between 235V and 245V here when PV is producing).

Wimpie-ccc avatar Jun 05 '26 22:06 Wimpie-ccc

I've raised a testing branch for this in my fork of the repo. No warranties, tested only for a two hours, not merge-ready, not satisfied with "fairness" / power-budget distribution between batteries, but if anyone wants to test & share experiences: https://github.com/nickles-lee/marstek-venus-rs485-node-red/pull/2

I was at least able to saturate phase 3 with charging batteries, kick on the induction stove, and I observed it throttling down to a safe threshold within ~10s on the "Safe" sensitivity setting.

nickles-lee avatar Jun 07 '26 12:06 nickles-lee

I think I'm going to want to get two PRs merged (offline tests + #139 ) before I progress the PR for phase protection, but at least in my house, it's quite promising:

Approx. 1 day view: Image

A more zoomed-in view of a period where phase 3 is running at full load: Image

Start of a brief overload to 32A, caused by an appliance switching on while the batteries had Phase 3 fully loaded: Image

End of the overload, 10s later Image

Note that I've validated phase protection during the time period where the batteries are charging. I haven't tested phase protection when the batteries are on standby / not actively charging.

nickles-lee avatar Jun 20 '26 12:06 nickles-lee