fix(genetic): keep a started home appliance run until the device reports it finished

A re-plan treated a running home appliance as not started. In its start
slot it could pick another start of equal cost and switch the appliance
off; after the start slot it could only plan a new complete run later; and
when no complete run fitted into the rest of the window, the DAILY cycle
was dropped and the running appliance got OFF.

The executor now reports the start of a planned run as UNIX seconds under
`<device_id>.run_started_at` (setting `run_started_measurement_key`) and 0
when the device reports the run as finished. The device decides when that
is, also before or after the configured duration. Until then the GENETIC
optimizer places the remaining energy from now on as fixed load,
independent of windows, deadline and genes, sends RUN, counts the run as a
cycle of its start day and plans further cycles after its end and gap. A
run past its duration keeps the current slot without extra energy; a start
more than two run durations ago, or an invalid value, is logged and
ignored.

Refs: #1548
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
SchaafAlexander
2026-11-15 13:54:22 +01:00
committed by Bobby Noelte
co-authored by Claude Opus 5.5
parent 0bf9f50b97
commit 4693e1fa97
13 changed files with 676 additions and 21 deletions
+16
View File
@@ -512,6 +512,22 @@ the measurement store, under the key configured in `cycles_completed_measurement
to `{device_id}.cycles_completed`). This lets the optimizer skip cycles the appliance has already
completed earlier the same day.
A run that has started is kept until the device reports it as finished. The executor writes the
start of the run as UNIX time in seconds to the key configured in `run_started_measurement_key`
(defaults to `{device_id}.run_started_at`) when it switches the appliance on for a planned run.
When the device reports the run as finished, the executor writes `0` and increments the completed
cycles. The device decides when that is: a water heater may finish early because its thermostat
reached the temperature, a dishwasher may run longer than its profile. Until then, every re-plan:
- places the remaining energy of the run from now on, independent of time windows and deadline,
- sends RUN for the appliance and does not move or stop the run,
- counts the run as a cycle of its start day and plans further cycles after its end and
`min_cycle_gap_h`.
A run past its configured duration keeps the current slot without extra energy. A start more than
two run durations ago is taken as a stale report and ignored, as are invalid values; both are
logged.
:::{admonition} Note
:class: note
Unlike GENETIC0, the GENETIC algorithm can plan multiple cycles -- and therefore multiple starts
+4
View File
@@ -96,6 +96,10 @@ time, charging power and supported charge rates.
slots). The energies, costs and SoC change of that slot cover only that part, and its
charge/discharge factors are the power for the remaining time. A run on a slot
boundary plans a full first slot (`first_slot_fraction` 1.0).
- Executors of household appliances should report a started run: write its start (UNIX
seconds) to `<device_id>.run_started_at` when switching the appliance on, and `0` when
the device reports it finished. Without it, a re-plan may move or stop a running
appliance.
- Runtime purchase and sale prices are **currency per Wh**: 0.30 EUR/kWh is 0.00030 EUR/Wh.
Provider power forecasts are converted by EOS; do not convert them a second time.
- Read returned timestamps and interval information instead of assuming 24 hourly values