Commit Graph
1199 Commits
Author SHA1 Message Date
Bobby NoelteandClaude Opus 5.5 3256bca88e docs(ai): group the tests of one unit in a test class
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-24 11:52:08 +01:00
Bobby Noelte 34c19c3573 fix: render datetime model keys in their timezone, not the host's
Additional changes
- A series created from pandas takes the timezone of its index, like a data frame.
- Row methods of a data frame find their rows when `tz` differs from the host timezone.
- to_timezone(date_time=...) names the timezone of an aware date-time, or the Etc/GMT zone of its UTC offset.
- to_timezone(utc_offset=...) raises for offsets without an Etc/GMT zone instead of returning an invalid name.
- Group the to_timezone tests in TestToTimezone.

Closes #1592
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-24 11:52:08 +01:00
NormannandBobby Noelte 0e0a544371 build(deps): update dependencies 2026-11-24 11:32:58 +01:00
43c61b53bd docs: say that the CI tags the release and a maintainer publishes it
bump-version.yml tags the release commit and starts the image build,
but creates no GitHub Release. The release docs said that the CI
publishes the GitHub Release. Step 4 now names the tag and the Docker
images, and a new step 7 says that a maintainer publishes the GitHub
Release for the tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 22:10:59 +01:00
c07f7f41ed ci: start the release image build again when the release job is rerun
A rerun of the Bump Version job finds the tag it pushed before, so
tagged is false and the image build was skipped: a failed dispatch
could not be retried. The build now starts whenever the release tag
points to the commit of the run. The release docs name the manual
fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 22:10:59 +01:00
053e22e7fe ci: build the Docker images for the release tag
bump-version.yml pushes the release tag with GITHUB_TOKEN. Events from
GITHUB_TOKEN do not start other workflows, so docker-build.yml never
ran for v0.3.0, and Docker Hub has no 0.3.0 or 0.3 image. bump-version
now starts docker-build.yml for the new tag with a workflow_dispatch
event, which GITHUB_TOKEN may trigger. docker/metadata-action takes the
version tags from the tag ref, also for workflow_dispatch.

Additional changes
Describe the tag and the Docker images in the release process docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 22:10:59 +01:00
7785e09c59 test(prediction): run the default update test in a fixed zone
test_update_method_with_defaults expected the prediction window to end 48
real hours after the start, given in the local zone of the test run. The
window ends at the same wall-clock time, as documented in end_datetime, so
the test failed where DST ends within the window, e.g. in
America/Los_Angeles on 2024-11-03. The start is now given in a fixed zone,
and a second case crosses the end of DST on purpose and checks the 49 hours.

Fixes #1570

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 21:57:53 +01:00
bf8939a8b7 test(weather): build Open-Meteo test times with datetimeutil
The irradiance tests create their lookup times and the one-hour offset
with to_datetime and to_duration, as the project rules require for new
code, and share one helper for the mocked HTTP response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 21:45:04 +01:00
926818fbd4 fix(weather): map instantaneous Open-Meteo GHI, DNI and DHI
WeatherOpenMeteo stored Open-Meteo's direct_radiation, the beam on the
horizontal plane, as weather_dni. PVForecastPVLib transposes weather_dni
as direct normal irradiance, so for a 40 deg south plane in Berlin the
clear-sky plane-of-array irradiance came out at 25 % of the true value
on 21 December, 58 % on 21 March and 80 % on 21 June. The plain
Open-Meteo radiation variables are also means over the preceding hour,
stored at the hour's end, while EOS weather irradiance is the value at
the record time, as BrightSky and ClearOutside derive it from the cloud
cover and as PVForecastPVLib reads it with the sun position at the
record time.

The provider now requests and maps shortwave_radiation_instant,
direct_normal_irradiance_instant and diffuse_radiation_instant. The
instantaneous variables (temperature, humidity, clouds, wind) keep
their stamps; no record is shifted.

test_update_data and test_openmeteo_radiation_mapping pinned the old
mapping of direct_radiation to weather_dni and now expect the instant
variables. The recorded sample response predates them, so the tests
add clear-sky irradiance to it instead of a new recording.

Additional changes
Describe the irradiance of the OpenMeteo provider in the prediction docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 21:45:04 +01:00
966fc7ba7f fix(docs): install the Read the Docs build with uv from uv.lock
.readthedocs.yaml installed requirements-dev.txt, which #896 removed.
Every Read the Docs build since 2026-02-23 failed with "Could not open
requirements file", so the published documentation stayed at 0.2.0.
Read the Docs now runs uv sync with the dev extra, which holds the
Sphinx packages, and takes the versions from uv.lock like CI.

Additional changes
Build the documentation with Python 3.13 like CI, pre-commit and Docker
Test that every file, path and extra in .readthedocs.yaml exists

Fixes #1561

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 21:42:15 +01:00
3035ec0a4b fix(prediction): key cached provider requests on the settings they read
The file cache keyed provider request methods on their arguments and
code only. They take no arguments besides self and read location,
planes, tokens and past days from the configuration, so after a
configuration change they got the response for the previous one until
the 1-hour TTL expired, also across restarts.

cache_in_file takes an optional key_context, called with the arguments
of each call; a hash of its result is part of the key. Each provider
request declares the settings it is built from with
cache_request("general/latitude", ...), which builds the key context
from them. A change of other settings, e.g. an import value or a tariff
that an adapter pushes on every run, keeps the cache entry. The MD5
digest of the declared values is computed once per settings generation:
ConfigEOS.settings_generation() counts every _setup() (merge, reset,
revert, update) and every set_nested_value().

cache_in_file also takes key_context_hold: after a change of the key
context, a further change within the hold keeps using the valid entry
of the context in use. The first change, a change after the hold and a
forced update apply at once. A result is only stored under the context
it was computed for. cache_request passes its keyword arguments on to
cache_in_file; with_ttl defaults to REQUEST_CACHE_TTL (1 hour) and also
sets key_context_hold, so settings changes cause at most one extra
request per provider and TTL.

In a simulation of 6 hours of 5-minute runs with an import value pushed
on every run and four location and plane edits, the weather and PV
requests run 6 times (as on main), and every edit reaches the provider
within the hour.

Additional changes
Test that every cached request declares the settings it reads, including
those read by helper methods of its module
Test the settings generation counter, the reuse of the digest, the hold
and the cache_request defaults and pass-through
Add general/timezone to BrightSky (in the URL) and Forecast.Solar
(fallback zone of the response)
Clear the hold state with the whole file cache
Add a CHANGELOG entry

Refs: #1559
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)
2026-11-20 19:06:40 +01:00
b944d4adfa docs(prediction): describe the update when a provider fails
Refs #1571

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:50:25 +01:00
14acf759a7 fix(cache): leave no empty cache file after a failed cached call
cache_in_file created the cache file before it called the function. When
the call raised, e.g. a provider request answered with HTTP 500, the
empty file stayed in the store until it expired, and the next call logged
"Read failed: Ran out of input" before it called the function again. The
function is now called first; a failed call leaves the store unchanged.

Refs #1571

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:50:25 +01:00
c8f793c203 fix(prediction): update all providers before reporting a failing one
The prediction container stopped at the first enabled provider that
failed to update, so the providers after it in the sequence were not
updated in that run. A failing weather provider, at the start of the
sequence, thus also kept the electricity price, feed-in tariff, load and
PV forecasts from being updated. The container now updates all providers
and then raises one RuntimeError with the failures of all enabled
providers; with one failing provider the message is unchanged.

Refs #1571

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:50:25 +01:00
867bc38fc0 fix(config): write a migrated config file in place only with a backup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:39:14 +01:00
fed03a0069 fix(config): write a migrated config file in place if it is not replaceable
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:39:14 +01:00
f3773de8f8 fix(config): never autosave defaults over an unreadable config file
Additional changes
The migration copies the old file to the backup instead of moving it and replaces the file atomically, only after the migration succeeded.
An explicit save keeps a copy of a file that could not be loaded and serializes the configuration before it opens the file.
The configuration guide describes the migration backup and what happens to a file that cannot be loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:39:14 +01:00
887bae551b ci: install the locked environment in the test workflow
uv sync without --locked resolves again when uv.lock is out of date.
The test jobs of #1569 installed pydantic 2.14.3 and pydantic-core
2.50.4, while uv.lock pins 2.14.2 and 2.50.2, and passed. With --locked
the test jobs fail on a stale lockfile like the pre-commit job and test
the versions uv.lock pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:36:11 +01:00
1768e11020 ci(dependabot): update Python dependencies together with uv.lock
Dependabot used the pip ecosystem, which changes only pyproject.toml.
The pre-commit job runs uv with --locked, so every Python dependency
pull request (#1565 to #1569) failed with "The lockfile at uv.lock
needs to be updated". The uv ecosystem updates uv.lock as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 18:36:11 +01:00
4b15419b4d build(make): cap the parallel workers of test-ci
test-ci ran the tests without a server with `-n auto`, one pytest-xdist
worker per core. On a machine with 32 cores and 16 GB of memory this
exhausted the threads (Windows, `RuntimeError: can't start new thread`)
or the memory (WSL); with eight workers all parts passed (reported in
the review of this pull request).

The target now adds `--maxprocesses=$(TEST_CI_MAX_WORKERS)` with a
default of 8, so it still starts one worker per core, but at most
eight. `make test-ci TEST_CI_MAX_WORKERS=<n>` changes the limit. CI is
not affected: its jobs call pytest themselves, on runners with four
cores.

Additional changes
Describe the limit, `--maxprocesses` and `PYTEST_XDIST_AUTO_NUM_WORKERS`
in the developer documentation

Refs #1553

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
57905b2024 ci: run the tests in parallel jobs and speed up the Sphinx build
The single test job ran all tests one after the other on one runner,
including the Sphinx build and the Docker checks (11-19 min). It is now
split so that every test still runs exactly once:

- docs-test, docker-test: the Sphinx build (new marker "docs") and the
  Docker / Home Assistant add-on checks ("docker") in jobs of their own.
- test-server: the tests that start EOS or EOSdash on the fixed ports.
  The collection hook marks every test that uses the xprocess fixture
  with "eos_server" and puts them into one xdist group, so
  "pytest -n auto --dist loadgroup" also works locally. A test that
  binds the ports without a fixture carries the marker itself.
- test-shard: all other tests in four shards of about equal runtime
  (scripts/shard_test_files.py, runtimes in scripts/test_durations.json),
  each with pytest-xdist.
- test-count: fails if these parts do not add up to the tests of one
  plain run.
- test: keeps the name of the required check. It prints the combined
  coverage report and fails if any of the jobs above failed.

COVERAGE_CORE=sysmon measures line coverage through sys.monitoring:
the report is the same, the test time drops by about a third. The
combined report misses 1-3 statements more than a single run, in lines
that only run when a test finds state left by an earlier test.

The Sphinx build spent 74 % of its time in one search of
PythonDomain.find_obj (sphinx-doc/sphinx#11282). The local extension
docs/_ext/pyxrefindex.py answers it from an index of name endings with
the same matches in the same order; a build has a byte-identical
objects.inv. It copies the logic of Sphinx 9.0.4 and is only active for
that version; TestPyXrefIndex compares it with the installed Sphinx and
fails after a Sphinx update until the version is raised. The
documentation test builds with -j (up to four jobs); its pages can
differ from a serial build in the target of ambiguous cross-references.
Read the Docs builds without -j. Sphinx build on GitHub runners:
427-480 s -> 180-233 s.

make test-ci runs the commands of these jobs one after the other.

On GitHub runners the tests are done after about 2 minutes; the
required check ends with docs-test after about 4-5 minutes.

Additional changes
Add pytest-xdist to the development dependencies
List the 25 slowest tests in each test job (--durations=25)
Test version() directly; it was covered only through the Sphinx test
Add a "Keep Tests Fast" tip, the server marker rule, the extension and
test-ci to the development guide and the testing skill

Refs #1553

Co-authored-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-opus-5-5)
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
e2726354c2 test: make slow and order-dependent tests fast and independent
Slow tests:
- TestPerformance inserted 10 000 records three times per backend. One
  test per backend now times insert, save and load on the same records,
  with the same assertions.
- test_measurement_realtime_stream slept one second per update, 20 s per
  backend. The updates use synthetic timestamps one second apart in the
  recent past, without a pause, and send the same duplicates,
  out-of-order and burst writes.
- test_readers_never_see_a_partial_document: the readers spun on the
  cache and kept the writer waiting for the GIL (~50 s). They now yield
  with time.sleep(0) after each lookup (~0.5 s); a non-atomic save still
  fails the test 10 of 10 times.
- test_devicessettingsbattery.py compiled the same plain profile before
  each of its 235 tests. A module-scoped fixture compiles it once; a
  compiled profile is frozen and may be shared (20.8 s -> 9.4 s).
- The --finalize case of test_geneticoptimize.py runs 250 instead of
  400 generations. For this input and seed the best fitness is final in
  generation 213, and the solutions after 250 and 400 generations are
  identical field by field. The test checks the keys and the consistency
  of the result, not the schedule, so it detects the same as before
  (127 s -> 80 s on GitHub runners). test_genetic0optimize.py keeps 400.

Tests that depended on another test of the same process, found by
running them in another order and under pytest-xdist:
- TestPredictionContainer::test_len relied on a class flag that a
  TestPredictionProvider fixture set and never reset. Both fixtures now
  set the flags with monkeypatch.
- The EnergyCharts status code test got a cached response from an
  earlier test; it now calls _request_forecast(force_update=True) and
  asserts that the request was made.
- test_ingress_safe_links did not wait for EOSdash, which EOS starts
  after its own startup.
- test_forward_stream_truncates_very_long_line found the log queue left
  behind by test_server_start_eosdash (no worker, closed event loop). It
  installs its own queue now, and test_server_start_eosdash no longer
  leaves its queue behind. Dropping lines from a full queue was only
  covered through that left-over queue and gets a test of its own.

Refs #1553

Co-authored-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-opus-5-5)
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
ce7fb96faf fix(database): reopen SQLite at the current data folder
SQLiteDatabase resolved its file once, in __init__. open() then created
the directory of the current storage_path but connected to the old file.
Database keeps the backend while the provider stays the same, so after a
data folder change and a reopen, EOS kept reading and writing the database
of the old folder. LMDB resolves its directory on every open and was not
affected.

Tests showed it as order dependence: test_count_records[SQLite] found the
five records of test_load_records_with_range[SQLite] when both ran in a
row. Under pytest-xdist, ten SQLite tests failed this way.

open() now resolves the file from the current storage_path, like LMDB.

Refs #1553

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
00a39f75bf perf(datetimeutil): parse ISO 8601 instants without the format search
to_datetime() tried ten pendulum formats before an ISO 8601 date-time
with "Z" or an explicit offset reached pendulum.parse(). None of the
formats can match such a string (each is combined with a timezone
name), so every call paid ~190 µs for nothing. Database timestamps
("20241027T123456Z") take this path on every record lookup
(db_get_record, _db_timestamp_after, key_from_series), and so do API
and provider date-times.

These strings name one instant and are now parsed directly (~7 µs),
built with pendulum.datetime() like pendulum.parse(), so the result
keeps the same fold. Any other form, offsets of 24 hours or more and
out-of-range fields still go through the generic parser. Compared with
the previous to_datetime() over 162 432 calls (5076 strings, 8 target
zones): no difference in value, timezone, fold or raised exception.

DatabaseTimestamp.from_datetime() formats with an f-string instead of
the format-token parser of pendulum (6 µs -> 2 µs), with the same output
for every 4-digit year. Its docstring example shows the stored form
"20241027T123456Z".

The five DB/EnergyCharts test modules: 298 s -> 112 s.

Additional changes
Test the config returned to a re-entrant get_config(); the full suite
reached that line only as a side effect of slow tests

Refs #1553

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-20 07:15:33 +01:00
Bobby NoelteandClaude Opus 5.5 cc875f798c feat(measurement): treat long *_emr_keys meter gaps as unknown
Additional fixes:
Add timezone to loadakkudoktoradapted tests datetime generation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-15 18:30:00 +01:00
Bobby NoelteandClaude Opus 5.5 f441759dfa fix(measurement): use quality-aware meter energy for load and PV
Additional fixes
Measurement.meter_energy_kwh converts meter energy over the whole period in one read; the 31-day and 10000-interval limits apply to the public energy queries only.
Load intervals a meter does not fully cover are NaN and the load adjustment skips them; load_total_kwh returns an empty array for an empty store and keeps full last intervals.
The load adjustment compares over the period the load meters report, skips a stale load meter period and says when no load meter is configured.
PV calibration, snow feedback and the load adjustment fall back without measurements when a conversion fails, logged as error once per failure streak and consumer.
Measurement.keys_first_datetime and keys_last_datetime find each meter's first and last valid reading in bounded scans, keep each meter's newest reading and return stamps in the configured zone.
Measurement.keys_common_period derives the common meter period for PV calibration and the load adjustment and names the meter that ends it, also when meters share no period.
PV calibration warns once per stale period when a stopped PV meter holds it on old data; snow feedback warns once about a stale feedback meter.
Lasting meter conditions (silent, reset, gap, replaced meter, no shared period) are warned once per condition and consumer through one helper and warned again when they recur.
A replaced meter whose readings touch the new one is reported; a single reading is not; a meter group waiting for its second reading is an info once.
The PV meter resolution is detected from valid readings only (pre-existing), using one shared valid-reading rule in energy.py.
Stale meter stamps are compared with compare_datetimes; new meter tests create durations with datetimeutil.
The unused legacy Measurement._energy_from_meter_readings is removed; its test scenarios cover meter_energy_kwh.
The converter's range error no longer mentions the API's 31-day limit, and its duplicate interval check is gone.
Measurement and prediction docs describe the meter coverage rule, even gap spreading and when the load forecast stays unadjusted.
Tests reset the warn-once state of the shared measurement store and restore the EMS start they change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-15 18:30:00 +01:00
Bobby NoelteandClaude Opus 5.5 2bfb6eafab fix(pvforecast): align the calibration window to the UTC slot grid
Additional fixes
PV meter energy comes from the quality-aware conversion.
Calibration rows are binned by interval start with end-stamped rows.
The fit covers only the period every PV meter covers and stays inside its lookback.
The meter resolution is judged only where every PV meter reports.
Snow feedback derives its window from the same slot window helper and shares one PV meter read per forecast with calibration.
Window bounds and pandas timestamps are converted in one place, always to UTC; fit days are counted in the configured zone.
Calibration tests write meters in bulk, stamp them in the configured zone and check every azimuth bin; snow feedback has its own slot window test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-15 18:30:00 +01:00
NormannandGitHub 6fad58655f build(deps): update dependencies
dnspython 2.9.2
Tornado 6.6.1
2026-11-15 17:09:24 +01:00
45a6377b60 fix(genetic): keep a deadline from capping the DAILY appliance estimate
The tail estimate queried its probe appliance with the configured
deadline. A deadline inside the control horizon then left no start on
the following days: with BEST_EFFORT the 48 h tail held one run and
logged "deadline can not be met" twice per run, with STRICT it held no
appliance load. The deadline only limits the run it was set for, so the
probe leaves it out.

Additional changes
Test the tail load with a deadline inside the control horizon for both deadline policies

Refs: #1495
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)
2026-11-15 15:10:57 +01:00
d9a5ac0b0b fix(genetic): count a run in progress in the DAILY appliance estimate
Since #1549 a run in progress counts as the run of its day and delays
the next cycle until after its end and the minimum gap. The DAILY
appliance estimate of the tail and terminal value now does the same
(completed_cycles_on, next_cycle_earliest_slot), so a running appliance
is not expected to run a second time on that day.

Additional changes
Format the tail load expression and the estimate docstring (ruff format)
Test the estimate with and without a reported run in progress

Refs: #1495
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)
2026-11-15 15:10:57 +01:00
ChenYi-NnergyandBobby Noelte a344e04ca5 fix(genetic): include DAILY appliance load in tail and terminal value
With terminal_value_mode AUTO, the tail and the continuation curve only
saw the base load: appliance load is added to consumption inside
simulate() but never reached either curve. Stored battery energy was
therefore valued at 0 ct/kWh over a wide SoC range, and the optimizer
drained the battery to run scheduled appliances instead of using cheap
night grid energy.

Both curves now include the expected load of DAILY home appliances: one
run per local day and cycle at its earliest allowed start within its
window, with the minimum cycle gap. Days whose run is already planned in
the control horizon are not counted again in the tail. ONCE appliances
are left out.

Squashed from PR #1540 (6 commits) onto main e40ff7f.

Closes: #1495
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
2026-11-15 15:10:57 +01:00
Bobby NoelteandClaude Opus 5.5 ebb440238a chore: untrack the generated docs that test_doc writes into tests/testdata
Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:36:53 +01:00
e40ff7f6e3 fix(genetic): date a run in progress in the time zone of the horizon
The start day of a run in progress decides which DAILY cycle it counts
for. Take it in the time zone of slot 0, which also dates the cycles.

The cycle counting test gave its times with a +01:00 offset, so on a
runner in UTC the run started on the previous day and was rightly not
counted for today. It now uses local times without offset and passes in
local time zones from UTC-12 to UTC+14.

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)
2026-11-15 13:54:22 +01:00
4693e1fa97 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)
2026-11-15 13:54:22 +01:00
0bf9f50b97 fix(genetic): plan the running slot only for the remaining time
A run within a slot (e.g. 10:45 with hourly slots) planned slot 0 as a
full slot, although the SoC is measured at the run time. Slot 0 now moves
only the remaining part of the slot energy: battery, EV and inverter
energy caps, SoC power limit tables and the slot's PV and load forecast
are scaled by first_slot_fraction; efficiency curves are read at the
power of that part. The plan's SoC headroom clamp of the AC charge factor
uses the same part, and the GENETIC result reports first_slot_fraction.
A run on a slot boundary is unchanged.

Additional changes
Pin GENETIC test start times to the full hour; their results now depend on seconds within the slot
Document first_slot_fraction for consumers of GENETIC results

Refs: #1543
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)
2026-11-15 12:45:56 +01:00
Bobby Noelte 7e10f64048 chore: development version update (incl. home assistant config)
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2026-11-12 22:59:31 +01:00
Bobby NoelteandClaude Opus 5.5 88904874e7 fix(version): keep VERSION_DATE in _version_date.py up to date
Additional fixes
Use a portable shebang instead of the workspace .venv in update_version.py
Update the stale VERSION_DATE of 2026-02-24 to 2026-11-12

Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 22:01:05 +01:00
Bobby NoelteandClaude Opus 5.5 14e439c265 ci: run the AI self-review check on pull_request
GitHub blocks pull_request_target by default in public repositories from
December 2, 2026. The ai-self-review workflow now runs on pull_request.
It still checks out and runs the check script of the base branch and no
other code of the pull request. The workflow file itself now comes from
the pull request, so a pull request that changes it can weaken its own
check. .github/CODEOWNERS therefore makes a maintainer the code owner of
the workflows, CODEOWNERS and the check script; this is enforced once the
branch protection of main requires a review from code owners.

Additional changes
- Record the switch in ADR 0002, which supersedes the pull_request_target
  consequence of ADR 0001.
- Skip the comment step for pull requests from forks, whose token is
  read-only, and point their error message to the job summary only.
- Describe the trigger, code owners and fork limits in docs/develop/ai.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-12 22:00:42 +01:00
NormannandGitHub eb4b34f194 build(deps): combine Dependabot updates (#1527)
types-PyYAML 6.0.12.20260906 → 6.0.12.20261103
types-requests 2.33.0.20261006 → 2.33.0.20261030
tzfpy 2.1.1 → 2.1.2
cachebox 6.2.8 → 6.2.10
pypdf 6.21.4 → 7.0.0
2026-11-12 19:34:57 +01:00
b4d2d7b2aa fix(genetic): same plan on every CPU (fixed-order dot products, stable sort of equal prices) (#1518)
* fix(genetic): sum the self-consumption dot products in a fixed order

GENETIC gave different plans for the same input and seed on different
CPUs. SelfConsumptionProbabilityInterpolator computed its two dot
products with np.dot, which calls BLAS; OpenBLAS picks a ddot kernel per
CPU at run time (and macOS uses Accelerate), and the kernels sum in
different orders, so the result differs in the last bit. The optimizer
compares fitness values exactly, so one bit is enough for a different
plan.

fixed_order_dot() adds the rounded products in index order with Python
floats, without BLAS: the same result on every CPU. The vectors have one
entry per 50 W load bin and the results are cached per (load, PV) pair,
so the run time does not change noticeably. Plans change once in the
last bits compared with the previous np.dot result of a given CPU.

* fix(genetic): sort equal prices of the terminal value window in slot order

np.argsort with the default kind (quicksort) leaves the order of equal
values to the platform: NumPy sorts with SIMD kernels on x86-64
(x86-simd-sort) and with introsort elsewhere. Slots with the same price
then fill the terminal value curve in another order, the battery
capacity cuts it elsewhere, and the same input and seed gave another
plan on x86-64 than on aarch64 (seen as a native-vs-Python compare
difference on x86-64 in
test_plan_keeps_reserve_for_a_peak_beyond_the_control_horizon).

The window is now sorted with kind="stable": slots with the same price
keep their slot order on every platform. Same goal as the dot product
change in this PR: the same input gives the same plan on every CPU.

Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:05:43 +01:00
43cb0f04b2 docs(eosdash): describe the setup assistant (#1516)
Add a how-to page for the first setup with the EOSdash setup assistant and link it from the documentation index, the getting started tutorial and the README.

The status of the measurements step is derived from the configuration only. Say what that means for a system that sends the state of charge on its own.

Add the new Home Assistant step to the list of steps, say that the Home Assistant 
adapter needs EOS to run as an add-on and that an automation has to act on the 
instructions, and update the screenshot to the eleven steps.

The devices step of the setup assistant now asks for the size of each unit,
because the packaged battery and inverter profiles are generic and give no
capacity or nominal power. Say so on the setup page, point to the Profiles
page and link the battery configuration and the inverter profiles.

Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 14:47:10 +01:00
fca524a913 feat(eosdash): add the remaining steps to the setup assistant - #1515⁠
The setup assistant only covered the location, the horizons and the energy
management, and sent the user to the Config page for everything else.

Add the steps PV system, weather, prices and fees, load, devices and
measurements, each with an explanation, an example and a check of what is
still to do.

Add a Home Assistant step after the measurements step that explains what EOS
reads from and writes to Home Assistant, with a template sensor and an automation
as example. Its status reports a missing state of charge mapping, missing instruction
entities and an adapter that is selected while EOS does not run as an add-on. The
measurements step keeps the choice of the adapter.

Add examples for an inverter, an electric vehicle and a home appliance.

A step can now show configuration values depending on the value of another
one (WizardChoice), so that only the settings of the selected provider are
shown. The horizon of the selected optimization algorithm uses the same
mechanism instead of a placeholder in the configuration name.

Describe the profiles, point to the Profiles page and use the
profile_adjustment settings in the examples. The packaged profiles are
generic and give no size, so the devices step now reports a battery,
electric vehicle or inverter whose effective nominal capacity or power is
unknown. The changelog entry names the Home Assistant step.

Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-12 13:35:37 +01:00
8e94ab02d1 fix(eosdash): describe the automatic saving of the configuration in the setup assistant
The setup assistant said a changed value is only written to the configuration file by the save button of the last step. By default EOS saves configuration changes on its own (general.config_save_mode AUTOMATIC). Say so, and show general.config_save_mode in the last step.

Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-12 10:40:57 +01:00
7f4014c408 feat(eosdash): add a setup assistant for the basic configuration
New users have to find the settings EOS needs among all configuration values
on the Config page, without a hint which ones matter or what is still missing.

The new Setup page takes the user through the configuration step by step.
Each step explains a few settings, gives an example, reports what is still to
do and shows the configuration cards of exactly these settings. The cards are
the ones of the Config page; the code that creates a card and sends an update
moved out of Configuration() into config_card() and config_update().

The assistant keeps no state: the step travels with the requests and the
status is derived from the EOS configuration, which is read and written
through the EOS server only.

First steps: location, horizons and energy management, save the configuration.

Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-12 10:40:57 +01:00
Bobby NoelteandClaude Opus 5.5 3bcc902104 feat(eosdash): add the profile page for battery and inverter profiles
The new Profiles page of EOSdash lists the user and packaged battery and
inverter profiles and edits them as JSON: preview without saving, save,
save as and delete, or revert a user profile to the packaged one. Saved
profiles apply at once.

One toolbar row holds the profile kind and profile selection, the Edit
button, the Share link and the status of the last action. A compact grid
summarizes the profile. A battery profile shows its charge and discharge
limit maps as heat maps as EOS evaluates them (with the exact hard
cutoffs) and its efficiency curves; an inverter profile its power at
45 degC, the DC→AC and AC→DC efficiency curves over the load fraction and
the power derating over the ambient temperature with 45 degC marked. Both
show the profile as highlighted JSON with a copy button. The sections are
collapsible and keep their state across actions.

The editor is shown only in edit mode: Edit in the toolbar opens it above
the plots, Close in the editor or Close editor in the toolbar ends it.
Edit mode is kept after preview, save and save as and across profile
changes.

Share opens a new issue with the battery or inverter profile issue form,
filled in with the profile, so users can propose their profiles for
packaging with EOS; each form asks for consent to publish the values under
Apache-2.0. EOS sends nothing itself.

Additional changes
- Add a compact variant to ConfigSection and status messages in the theme
  colors, readable in dark mode, to the EOSdash components.
- Use the muted theme color for explanatory texts.
- Check profile names before saving.
- Show the paste instruction for profiles too large for the share URL as
  text, not only as tooltip; name the selections for screen readers.
- Keep the toolbar layout when the profiles cannot be listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-11 22:08:18 +01:00
Bobby NoelteandClaude Opus 5.5 faf37abfe7 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)
2026-11-11 22:08:18 +01:00
Bobby NoelteandClaude Opus 5.5 e255f987bf feat(devices): add battery profiles
A battery profile describes a battery model: the charge and discharge limit
maps over temperature and SoC, the charge and discharge efficiency curves
over C-rate, the technical SoC bounds, the hard temperature cutoffs and,
for a model, its nominal capacity and power limits. EOS packages the
generic profile generic-lfp; users add their own profiles.

A battery or electric vehicle selects its profile by battery_profile and
describes how the installation differs from it in profile_adjustment
(capacity, power limits of the installation, periodic full charge). The
effective values are resolved from both at the measured operating point
(temperature, SoC, power) and shown as effective_* fields.

The GENETIC simulation uses the limits and efficiencies of the profile over
SoC, with precomputed tables as a fast path; GENETIC0 gets the values at the
operating point. Optimization parameters are always valid: a battery whose
profile is missing, unreadable or invalid uses the packaged generic-lfp
profile, and the former defaults only if that is not usable either; each is
logged as error, and an optimization run is never cancelled because of a
battery.

Additional changes
- Add a generic device profile store: user and packaged profiles, atomic
  saves, compiled profiles cached per file and checked again at most once a
  second, plain file names as profile names ('schema' is reserved). On
  Windows, a save or read that collides with the other is retried briefly.
- Add the REST API /v1/profile to list the profile kinds and to list, read
  (document and JSON schema), save and delete profiles.
- Check the hard temperature cutoffs on the exact temperature.
- Resolve inhibited charging or discharging to a power of 0, e.g. for a cold
  battery; give GENETIC0 its own discharge limit for that.
- Limit generic profiles without own power limits to the former 5000 W.
- Accept only the implemented units; current limits need the nominal
  voltage.
- Migrate legacy battery settings into the profile adjustment, keep the
  former charge power limit as discharge limit (also for a Home Assistant
  entity on it) and report dropped efficiencies as errors.
- Limit GENETIC battery discharge by the discharge power.
- Allow battery profile lookups while the configuration is created.
- Resolve a battery once per configuration dump.
- Package the bundled profiles, document battery profiles and regenerate
  the configuration and OpenAPI documentation.
- Ignore the report PDFs written by the visualization tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-11 22:08:18 +01:00
Bobby NoelteandClaude Opus 5.5 dd41e5d57c chore(ai): add agent self-review and a CI check for agent-assisted PRs
Additional changes
Agents write a task plan to .scratch/<branch>/plan.md and self-review with code-review
Agents fix hard violations, report judgement calls and rerun the self-review before every push
Agents declare the review in a Self-review section of the pull request body
Add the ai-self-review workflow and scripts/check_pr_self_review.py for pull requests into main
Detect agents by Assisted-by or Anthropic Co-Authored-By trailers, body markers or the AI box
Fail only on a missing Self-review section or a missing, malformed or stale Reviewed SHA
Note an unticked AI-assisted box and malformed optional lines without failing
Comment on the pull request how to fix a failure and update that one comment on later runs
Show the same report in the job summary and accept Windows line endings in the body
Skip dependabot and release pull requests
Run on pull_request_target with the base branch's script, never pull request code
Add the pull request template: the pr skill's sections plus Checklist and Self-review
Require always valid optimization parameters in the energy-domain skill
Require datetimeutil for date and time handling in new and changed code in AGENTS.md
Require the Assisted-by trailer on agent commits in the commit-messages skill
Add tests for the check in tests/test_ai.py
Add GLOSSARY.md and the agent tracker docs in docs/agents/
Add decision record docs/adr/0001 with an ADR index in the docs toctree
Document the workflow in docs/develop/ai.md and CONTRIBUTING.md
Exclude docs/agents from Sphinx and PyMarkdown and ignore .scratch/
Document cz check instead of make gitlint for commit messages in docs/develop/ai.md

Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:37:33 +01:00
62cbf4cf2a fix(homeassistant): apply 0 and off from config entities, never add settings
The configuration sync of the Home Assistant adapter skipped every value that is false in
Python, so an entity state of 0 or off never reached the configuration. It also set any
path it was given: the documented example devices/batteries/0/capacity_wh named a device
"0" that does not exist, so EOS silently added a new battery with a random device id.

Apply every value except an unavailable or unknown entity, and only update settings that
exist; report other paths as an error. The example now addresses the battery by its
device_id.

Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:38:45 +01:00
elschmanandGitHub 1fda5f9201 fix(doc): compose file in README
Without a docker compose the recommended install part of the documentation will not work at all
2026-11-11 09:36:16 +01:00