Skip to content

planner_self imports grid when PV forecast overestimates (regression from #124) #130

Closed

Description

@frahlg

Symptom

Operator report (2026-04-19): Running in Smart self-consumption (planner) mode, the site imports from the grid even when PV is producing and load is low. Switching to manual self-consumption makes the battery behave correctly (absorb surplus / cover load reactively).

Root cause

After #124, planner_self defaults to the energy-allocation dispatch path (State.UseEnergyDispatch = true). The dispatch converts the MPC plan's BatteryEnergyWh per slot into an instantaneous power target and commands the battery blindly:

targetTotalW = remainingWh * 3600 / remainingS
totalCorrection = targetTotalW - currentTotal

The PI on grid flow is reset (state.SetGridTarget(0); state.PI.Reset()), so nothing reacts to the live site meter inside a slot. The architectural contract (docs/plan-ems-contract.md) says "grid is the residual" — correct for planner_arbitrage, wrong for planner_self.

The DP enforces ModeSelfConsumption's grid-crossing invariant only on forecast. When the PV forecast overestimates vs actual conditions, the plan's committed charge rate exceeds actual surplus → battery pulls the delta from the grid.

Expected behavior

planner_self should execute as reactive self-consumption (PI-on-gridW=0, identical to manual self_consumption), with a per-slot idle gate from the plan: when the DP chose not to participate this slot (because a later slot is more optimal for charging), the battery is held at 0 and PV flows to grid. Otherwise, the battery reacts to the live meter exactly like manual self-consumption.

UI tooltip already promises: "Forecast-aware battery schedule that only covers local load or absorbs PV surplus. Never imports to charge, never exports via the battery." Execution must match the promise.

Scope

  • planner_self only — planner_cheap and planner_arbitrage keep the energy-allocation path (Wh-per-slot is the point there).
  • No config migration. planner.legacy_dispatch still applies to cheap/arbitrage.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions