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)
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)