Skip to content

Commit 526ad4b

Browse files
Merge pull request davidusb-geek#934 from OptimalNothing90/fix/875-inverter-ac-default
fix: restore hybrid inverter AC power defaults to 5000 (davidusb-geek#875)
2 parents 7bbc376 + 4414ef9 commit 526ad4b

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

‎src/emhass/data/config_defaults.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
"modules_per_string": [16],
104104
"strings_per_inverter": [1],
105105
"inverter_is_hybrid": false,
106-
"inverter_ac_output_max": 0,
107-
"inverter_ac_input_max": 0,
106+
"inverter_ac_output_max": 5000,
107+
"inverter_ac_input_max": 5000,
108108
"inverter_efficiency_dc_ac": 1.0,
109109
"inverter_efficiency_ac_dc": 1.0,
110110
"inverter_stress_cost": 0.0,

‎src/emhass/static/data/param_definitions.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@
249249
"friendly_name": "Max hybrid inverter AC output power",
250250
"Description": "Maximum hybrid inverter output power from combined PV and battery discharge.",
251251
"input": "int",
252-
"default_value": 0,
252+
"default_value": 5000,
253253
"unit": "W"
254254
},
255255
"inverter_ac_input_max": {
256256
"friendly_name": "Max hybrid inverter AC input power",
257257
"Description": "Maximum hybrid inverter input power from grid to charge battery.",
258258
"input": "int",
259-
"default_value": 0,
259+
"default_value": 5000,
260260
"unit": "W"
261261
},
262262
"inverter_efficiency_dc_ac": {

‎tests/test_defaults_smoke.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import pathlib
23
import unittest
34

@@ -80,3 +81,44 @@ async def test_perform_optimization_with_config_defaults_json_runs(self):
8081
emhass_conf,
8182
)
8283
self._build_and_run(retrieve_hass_conf, optim_conf, plant_conf)
84+
85+
def _run_hybrid_status(self, ac_output_max):
86+
"""Run a hybrid-inverter optimization with PV present; return optim_status."""
87+
plant_conf = copy.deepcopy(self.plant_conf)
88+
plant_conf["inverter_is_hybrid"] = True
89+
plant_conf["inverter_ac_output_max"] = ac_output_max
90+
plant_conf["inverter_ac_input_max"] = ac_output_max
91+
n = 48
92+
freq = self.retrieve_hass_conf["optimization_time_step"]
93+
tz = self.retrieve_hass_conf["time_zone"]
94+
idx = pd.date_range("2024-01-01", periods=n, freq=freq, tz=tz)
95+
p_pv = np.full(n, 3000.0)
96+
p_load = np.full(n, 1000.0)
97+
ulc = np.full(n, 0.2)
98+
upp = np.full(n, 0.1)
99+
df = pd.DataFrame({_VAR_LOAD_COST: ulc, _VAR_PROD_PRICE: upp}, index=idx)
100+
opt = Optimization(
101+
self.retrieve_hass_conf,
102+
self.optim_conf,
103+
plant_conf,
104+
_VAR_LOAD_COST,
105+
_VAR_PROD_PRICE,
106+
"profit",
107+
emhass_conf,
108+
logger,
109+
)
110+
res = opt.perform_optimization(df, p_pv, p_load, ulc, upp)
111+
return res["optim_status"].iloc[0]
112+
113+
def test_hybrid_inverter_feasible_on_default_ac_output_max(self):
114+
"""Regression for #875: the default inverter_ac_output_max must let a hybrid
115+
inverter solve. It regressed to 0 in the #830 config alignment, which caps
116+
hybrid AC output at 0 W, so any PV has nowhere to go and the solve is infeasible.
117+
"""
118+
status = self._run_hybrid_status(self.plant_conf["inverter_ac_output_max"])
119+
self.assertIn("Optimal", status)
120+
121+
def test_hybrid_inverter_infeasible_when_ac_output_max_zero(self):
122+
"""Locks the failure mode: ac_output_max=0 caps hybrid AC output at 0 W."""
123+
status = self._run_hybrid_status(0)
124+
self.assertNotIn("Optimal", status)

0 commit comments

Comments
 (0)