Pin result, conversion, plan and visualization of golden runs. Drive GENETIC through the optimizer interface and registry. Move GENETIC into one directory with role-named modules. Prepare every run input once, run from the parameters. Fall back instead of cancelling the optimization run. Simulate battery, EV and inverter from frozen dataclasses. Simulate the home appliance from frozen dataclasses. Convert and visualize from the parameters and result only. Serve GENETIC from its own router. Return a frozen result, build responses in the API. Echo the request as sent, not with an invented time window. Additional changes - Pin that the result does not depend on the number of evaluation workers. - Run the golden module in UTC: until the request date-times are held in UTC they render in the host time zone. - Add Optimizer.run_clock(), so the EMS gets slot length and time zone without GENETIC settings. - Rename ConfigOptimizationRequest, RuntimeForecasts and GeneticCommonSettings as ADR 0010 asks. - Correct the request example in ADR 0010. - Record the renamed OpenAPI schemas in CHANGELOG.md and the upgrade guide. - Add replay files that reproduce each golden result from its parameters. - Drop OptimizationBase from the algorithm. - Give the replay and worker tests own review files against xdist races. - Handle a failing preparation in the EMS like a failing run, no separate cancel path. - Record the fallbacks in CHANGELOG.md and the upgrade guide. - Without an inverter, buy the whole load from the grid instead of planning it at no cost. - Do not charge from the grid without any known price. - Treat an infinite value after the control horizon as a gap. - Correct the documentation that said missing forecasts cancel the run. - Copy the efficiency helpers and the self-consumption table evaluation into GENETIC. - Add CycleTimeWindowSequence, ConsumerScheduleMode and ConsumerDeadlinePolicy as contract names. - Hold the date-times of battery, EV and home appliance requests in UTC, so they render the same on every host. - Drop the UTC pin of the GENETIC golden module; the request date-times no longer depend on the host. - Copy the time window logic GENETIC needs into genetictimewindow.py. - Add ValueTimeWindow as a contract name. - Move the settings' to_genetic_*() converters into the preparation. - Drop the conversion's prediction reads and configuration fallbacks, which runs never reached. - Make the moved docstrings valid reST. - Remove the generic optimization solution route; each optimizer serves its own path. - Import the GENETIC settings from the package. - Record the removed route in CHANGELOG.md and the upgrade guide. - Make the terminal and tail value models frozen dataclasses. - Move the response models into geneticapi; remove geneticsolution and geneticabc. - Remove the legacy appliance start arrays and API, which read the wall clock. - Remove the time window helpers only they used. - Echo a start_solution without start_solution_datetime as sent. - Carry the previous solution's start in the run parameters. - Plan the home appliance cycles that fit, or leave the appliance out, instead of failing. - Move the appliance layout rules into geneticappliancelayout for the preparation. - Leave out a DAILY home appliance whose open windows leave no room for a run, with an error log, instead of silently. - Name the reason of the SoC fallback instead of Python's exception text. - Answer a solution request for an unknown algorithm with a 404 problem response. - Record the fixes in CHANGELOG.md and the upgrade guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Claude Code (claude-opus-5-5)
4.8 KiB
GENETIC configuration and manual acceptance
Apply the dependencies in review handoff before the complete GENETIC PR. These changes implement the feature branch on current EOS interfaces; they do not migrate a running Home Assistant installation automatically.
Configuration
Hardware and schedules belong in the typed devices maps, keyed by stable device
IDs. Configure an inverter and link its battery_id to the configured stationary
battery, or leave it empty when there is no battery. GENETIC currently supports one
inverter, one stationary battery, one EV and multiple household appliances. Explicit
validation rejects unsupported device counts and inconsistent links.
Example optimization settings (merge into an otherwise complete configuration):
{
"optimization": {
"algorithm": "GENETIC",
"genetic": {
"interval_sec": 900,
"horizon_hours": 24,
"tail_horizon_hours": 48,
"terminal_value_mode": "AUTO",
"measurement_max_age_seconds": 300
}
}
}
Use interval_sec: 3600 for hourly operation. AUTO evaluates available forecast
continuation; FIXED uses terminal_value_euro_per_kwh. Battery wear/LCOS remains a
separate cost. The tail affects scoring, never the emitted control horizon.
prediction.hours must cover the control horizon; shorter available tails are
clipped with diagnostics. Missing control forecasts do not cancel the run: each
gets a fallback for the run, logged as an error naming the forecast.
Old feature settings such as optimization.interval and flat terminal-value fields
migrate into optimization.genetic; explicit nested settings win. Check the saved
configuration after migration. GENETIC0 retains its separate settings and /optimize API.
Automatic GENETIC runs use the site's timezone derived from its coordinates, even when the server runs in UTC. An explicitly supplied run start retains its timezone. Stored results and warmstarts retain explicit timezones and absolute instants.
Requests and measurements
POST /v1/optimize runs GENETIC from configuration. An empty JSON object uses the
configured forecasts and fresh measurements. Runtime input may contain soc,
forecasts, start_solution and start_solution_datetime. Hardware overrides in
this body and query-string overrides are rejected. For example, with a configured
device ID storage:
{"soc": {"storage": 42}}
Request SoC values are integer percentages. Without an override, the measurement
key <device_id>-soc-factor must contain a recent factor from 0 to 1. Invalid,
future or stale measurements never become an assumed zero SoC. Completed appliance
cycles use their configured measurement key, default <device_id>.cycles_completed.
The start of a run in progress (UNIX seconds, 0 when finished) uses
<device_id>.run_started_at; such a run is kept until the device reports it finished.
Optional forecast arrays begin at local midnight, with one value per configured
slot: pv_forecast_wh and total_load are Wh per slot; electricity_price_per_wh
and feed_in_tariff_per_wh are currency per Wh. Provider PV/load power in W is
converted by the resolver. Supplied/imported sale tariffs are never replaced by
purchase prices. Missing optional arrays come from the selected providers.
Successful requests return the native result for that run. A failed run returns an error and cannot masquerade as a cached success. Generic solutions, plans and reports are derived from the same stored result. Warmstarts retain their source time so a later run shifts the previous controls to the new slot origin.
Retrieve the new GENETIC report with
GET /v1/energy-management/optimization/solution/GENETIC/pdf. It renders the stored
snapshot on demand; a missing result returns 404. The legacy PDF URL remains unchanged.
Manual acceptance after merge
- Back up the running configuration and update all merged EOS packages together.
- Confirm device IDs, inverter linkage, capacities, efficiencies, import/export limits, tariff units and the battery-export setting against your actual hardware.
- Check fresh SoC measurements and forecast coverage, then run Optimize at 60 and 15 minutes. Inspect timestamps, slot energies, native/generic results and the PDF.
- Compare AUTO and FIXED terminal value with identical inputs. Tail diagnostics must not appear as extra commands; sale prices must retain their configured signs.
- Exercise an EV departure and a flexible consumer schedule, including a completed cycle. Check permitted windows, required energy and device commands in your setup.
- Make a measurement stale or omit control forecast coverage and confirm the request fails explicitly. Verify the legacy GENETIC0 endpoint if your installation uses it.
Automated checks cover modeled behavior. The final manual test validates the actual HA entities, provider data and physical installation.