VALLEY_FILLING
Charges the battery from the grid when site import is low, to fill demand valleys.
| Mode string | VALLEY_FILLING (EMS_OP_VALLEY_FILLING) |
| Dispatcher | ems_main.py → control_logic_updated.control_step_valley_filling |
| Config block | functions.Valley_Filling |
| Queue source tag | control_logic (the writer's default) |
| Status | Implemented |
Purpose
A charge-only counterpart to peak shaving. When site import is below valley_threshold_kw it
charges the battery to soak up cheap/low-demand periods, bounded by window caps and the SOC ceiling.
How it decides
required_charge_kw = max(0.0, valley_threshold_kw - import_kw)
- Only acts inside an enabled
charge_windowsentry (timezone- anddays_of_week-aware). - Only charges when the site is importing. If the site is exporting, no charging is triggered by the valley rule.
- Applies the smallest of:
required_charge_kw,charge_power_limit_kw, the active window'scharge_cap_kw, and the per-PCS charge caps. - Hysteresis. If import sits inside the hysteresis band around the threshold, the previous setpoint is held (HOLD-LAST) rather than recalculated.
- The command is written as a negative kW (charge).
Configuration
functions.Valley_Filling
| Key | Live value | Meaning |
|---|---|---|
enabled |
false |
Master switch. |
valley_threshold_kw |
75 |
Import level below which charging is wanted. |
charge_power_limit_kw |
120 |
Plant-wide charge ceiling. |
max_soc_pct |
null |
Charge ceiling. Null ⇒ falls back to the PCS soc_limits.max_soc_pct. |
min_soc_pct |
null |
Not used — this mode never discharges. |
response_time_ms |
null |
Recorded; not used. |
timezone |
Europe/Stockholm |
Timezone for window evaluation. |
charge_windows[] |
5 entries | start, end, enabled, charge_cap_kw, days_of_week. |
optional.hysteresis_kw |
2 |
Deadband that triggers HOLD-LAST. |
optional.conflict_rule |
discharge_overrides_charge |
Documented; this mode has no discharge path. |
Safety
- Returns when
is_external_control_active(), whenenabledis false, or with no active PCS. - SOC gate is charge-only: judged against
max_soc_pct.min_soc_pctis deliberately ignored, so a low battery can still be filled. - Per-PCS caps from
power_limits.max_charge_kw, further bounded bycharge_cap_kwof the active window; final clamp inside_pcs_connect_and_set_power_kw.
Check: the second shipped window is
14:00 → 08:00, a window that wraps past midnight. Confirm the wrap is handled as you expect before enabling this mode.
Outputs
_pcs_connect_and_set_power_kw(cfg, pcs_id, -kw) → queue action set_power_kw, source control_logic.