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
+56 -1
View File
@@ -11044,7 +11044,7 @@
},
"type": "object",
"title": "Appliance Starts",
"description": "Scheduled run start times per appliance device_id as absolute local datetimes."
"description": "Scheduled run start times per appliance device_id as absolute local datetimes. A run in progress is listed first with its actual (past) start."
},
"appliance_deadline_missed": {
"additionalProperties": {
@@ -11299,6 +11299,25 @@
"GENETIC"
]
},
"run_started_measurement_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Run Started Measurement Key",
"description": "Measurement store key holding the start of the run in progress as UNIX time in seconds, 0 when no run is in progress. The executor sets it when it switches the appliance on for a planned run and sets 0 when the device reports the run as finished (then it also increments the completed cycles). The GENETIC optimizer keeps a run in progress until then. Defaults to '{device_id}.run_started_at' when null.",
"examples": [
"dishwasher.run_started_at",
null
],
"x-scope": [
"GENETIC"
]
},
"load_profile_power_w": {
"anyOf": [
{
@@ -11572,6 +11591,25 @@
"GENETIC"
]
},
"run_started_measurement_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Run Started Measurement Key",
"description": "Measurement store key holding the start of the run in progress as UNIX time in seconds, 0 when no run is in progress. The executor sets it when it switches the appliance on for a planned run and sets 0 when the device reports the run as finished (then it also increments the completed cycles). The GENETIC optimizer keeps a run in progress until then. Defaults to '{device_id}.run_started_at' when null.",
"examples": [
"dishwasher.run_started_at",
null
],
"x-scope": [
"GENETIC"
]
},
"load_profile_power_w": {
"anyOf": [
{
@@ -11810,6 +11848,23 @@
"description": "Cycles already completed on the first planning day.",
"default": 0
},
"run_started_datetime": {
"anyOf": [
{
"type": "string",
"format": "date-time"
},
{
"type": "null"
}
],
"title": "Run Started Datetime",
"description": "Start of the run in progress, None when the appliance is not running. The run is kept until the device reports it as finished: its remaining load is fixed from now on, independent of windows, deadline and gene, and it is not counted in 'completed_cycles' yet.",
"examples": [
null,
"2026-11-14T00:47:45+01:00"
]
},
"min_cycle_gap_h": {
"type": "integer",
"minimum": 0.0,