mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-11-13 09:13:30 +01:00
feat(devices): add inverter profiles
An inverter profile describes the technical data of an inverter model: its nominal AC power, the DC→AC and AC→DC efficiency curves over the load fraction (AC power relative to the nominal power), the AC charge power limit of the model, whether that limit also limits PV charging, and an optional power derating over the ambient temperature. Curves are read linearly and clamped at their ends, so every lookup yields a value. The packaged profile generic-hybrid has typical hybrid inverter efficiencies, no nominal power (the inverter device has to provide it) and full power up to 45 degC. Inverter settings name their profile (inverter_profile, default generic-hybrid) and hold the differences of the unit in profile_adjustment: nominal_power_w (replaces the profile value, required for a generic profile), max_power_w and max_ac_charge_power_w (installation limits that can only lower; an AC charge limit of 0 disables AC charging). The effective parameters are resolved at the ambient temperature of the inverter, given by the new measurement key <device_id>-temperature-degc (45 degC without a fresh value); the power derating lowers the maximum power and the AC charge limit. Optimization parameters are always valid: the GENETIC and GENETIC0 parameter preparation resolve the inverter with resolve_current_operating_parameters_or_defaults, which never raises. An unusable profile gives the generic-hybrid profile, a missing nominal power the fallback of 10000 W, an inverter derated to zero power the parameters at 45 degC, and no usable profile at all the profile adjustment with constant efficiency; each is logged as error. The GENETIC inverter takes the AC→DC efficiency curve of the profile, solved exactly on each linear piece of the curve (about 2 % longer runs); GENETIC0 keeps constant efficiencies and no longer replaces the configured inverters with the demo inverter; a battery, electric vehicle or inverter that cannot be prepared is left out of the GENETIC0 run, never replaced by a demo device. Configurations migrate: max_power_w becomes profile_adjustment.nominal_power_w, max_ac_charge_power_w moves into the adjustment, an ac_to_dc_efficiency of 0 keeps AC charging disabled, and the efficiency fields are dropped with an error log, as for batteries, so the profile efficiencies apply. Home Assistant config paths follow. Additional changes - Move the curve algorithms of the battery profile into profilecurve, so battery and inverter profiles share them; the battery profile keeps its document format and classes. - Move ProfileBaseModel, the strict base of profile documents, into profilestore. - Serve inverter profiles through the profile REST API. Refuse to delete a profile that a configured device uses and that has no packaged profile to revert to (409). - Share the measurement access of the device settings in devicemeasurement. - Rename check_battery_profiles to check_device_profiles; the device profile check at configuration setup covers inverters, too. - Document inverter profiles, their configuration, defaults and sharing; regenerate the configuration and OpenAPI documentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e255f987bf
commit
faf37abfe7
+19
-5
@@ -855,7 +855,7 @@ class TestDeviceSettings:
|
||||
with pytest.raises(ValidationError, match="device_id"):
|
||||
DevicesCommonSettings.model_validate({"batteries": {"house": {"device_id": "other"}}})
|
||||
|
||||
def test_check_battery_profiles_names_unresolvable_devices(self, config_eos):
|
||||
def test_check_device_profiles_names_unresolvable_devices(self, config_eos):
|
||||
# generic-lfp provides no capacity: the house battery lacks it, the car has it.
|
||||
devices = DevicesCommonSettings.model_validate(
|
||||
{
|
||||
@@ -863,15 +863,29 @@ class TestDeviceSettings:
|
||||
"electric_vehicles": {"car": {"profile_adjustment": {"nominal_capacity_wh": 60000}}},
|
||||
}
|
||||
)
|
||||
errors, warnings = devices.check_battery_profiles()
|
||||
errors, warnings = devices.check_device_profiles()
|
||||
assert len(errors) == 1
|
||||
assert "Battery 'house'" in errors[0]
|
||||
assert warnings == []
|
||||
|
||||
def test_config_logs_battery_profile_problems_once(self, config_eos, monkeypatch):
|
||||
def test_check_device_profiles_covers_inverters(self, config_eos):
|
||||
# generic-hybrid provides no nominal power.
|
||||
devices = DevicesCommonSettings.model_validate(
|
||||
{
|
||||
"inverters": {
|
||||
"inv1": {},
|
||||
"inv2": {"profile_adjustment": {"nominal_power_w": 5000, "max_power_w": 8000}},
|
||||
}
|
||||
}
|
||||
)
|
||||
errors, warnings = devices.check_device_profiles()
|
||||
assert len(errors) == 1 and "Inverter 'inv1'" in errors[0]
|
||||
assert len(warnings) == 1 and "Inverter 'inv2'" in warnings[0]
|
||||
|
||||
def test_config_logs_device_profile_problems_once(self, config_eos, monkeypatch):
|
||||
from loguru import logger
|
||||
|
||||
monkeypatch.setattr(ConfigEOS, "_battery_profile_problems", ((), ()))
|
||||
monkeypatch.setattr(ConfigEOS, "_device_profile_problems", ((), ()))
|
||||
messages: list[str] = []
|
||||
sink_id = logger.add(
|
||||
lambda message: messages.append(message.record["message"]), level="WARNING"
|
||||
@@ -888,7 +902,7 @@ class TestDeviceSettings:
|
||||
"devices/batteries/house/profile_adjustment/nominal_capacity_wh", 10000
|
||||
)
|
||||
assert not [m for m in messages if "Battery 'house'" in m]
|
||||
assert ConfigEOS._battery_profile_problems == ((), ())
|
||||
assert ConfigEOS._device_profile_problems == ((), ())
|
||||
finally:
|
||||
logger.remove(sink_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user