GitHub actions are not allowed to create commits on the main branch.
Instead create a pull request for bumping version to development
version.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This pull request prepares release **v0.3.0**.
Akkudoktor-EOS can now be run as Home Assistant add-on and standalone.
As Home Assistant add-on EOS uses ingress to fully integrate the EOSdash dashboard
in Home Assistant.
Adapters for Home Assistant and NodeRed integration are added. These adapters
provide a simplified interface to these HEMS besides the standard REST interface.
The prediction and measurement data can now be backed by a database. The database allows
to keep historic prediction data and measurement data for long time without keeping
it in memory. The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vacuum and compaction. Two database backends
are integrated and can be configured, LMDB and SQLight3.
New prediction providers allow to access OpenMeteo weather data and to define fixed
electricity prices for configurable time windows.
An anoying bug in the genetic algorithm that created unfeasable battery charge and
discharge amounts is now hopefully fixed.
In addition, bugs were fixed and new features were added.
See CHANGELOG for full details.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
* record battery SOC at the start of the interval for accurate display
* map battery charge rates to GeneticOptimizationParameters and update related logic
Instead of using the EV charge rates, the battery now has its own charge rate defined
in the GeneticOptimizationParameters to better separate those entities.
* separate raw gene values from SOC-clamped op factors
The genetic_*_factor columns in the OptimizationSolution dataframe now
always carry the raw gene values (optimizer intent), while the
battery1_*_op_mode / battery1_*_op_factor columns and FRBCInstruction
operation_mode_factor reflect SOC-clamped effective values that can
actually be executed given the battery's state of charge at each hour.
Adds GeneticSolution._soc_clamped_operation_factors():
- AC charge factor: proportionally scaled down when battery headroom
(max_soc - current_soc) is less than what the commanded factor
would store in one hour; zeroed when battery is full.
- DC charge factor: zeroed when battery is at or above max SOC.
- Discharge: blocked when SOC is at or below min SOC.
Both optimization_solution() and energy_management_plan() pass the
clamped values to _battery_operation_from_solution(), so the plan
instructions the HEMS receives reflect physically achievable targets.
* ensure max AC charge power is only used if defined
* update fixtures for PV suffix + SOC-clamp algorithm changes
* handle None case for home appliance start hour in simulation
if the hour is zero, the the home appliance wont start
* update handling of invalid charge indices in autocharge hours
Seems to be a bug, since all invalid indexes needs to be invalidated (also the first one)
* remove double code in simulation preparation and improve comments
* update version
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Co-authored-by: Christopher Nadler <christopher.nadler@gmail.com>
Ensure that the bidding zone in the request is correctly set to a
string value (not an enum).
This seems to be also an issue with python version < 3.11. Add safeguards
to only use python >= 3.11. Still keep a regression test for the enum
conversion to string.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This workflow file sets up CodeQL analysis for the repository, defining triggers for pushes and pull requests on the main branch, as well as a scheduled analysis. It includes configuration for multiple programming languages and initialization steps for CodeQL.
When running as Home Assistant add-on the only viable usage is running with
cyclic optimization. Make this the default to als propvide a better experience
for first time users. The optimization will start with demo data, which also
helps to configure Akkudoktor-EOS to the personal usage.
The disabling of the automatic energy management is now an explicit mode
"DISABLED".
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Add a fixed electricity prediction that supports prices per time window.
The time windows may flexible be defined by day or date.
The prediction documentation is updated to also cover the ElecPriceFixed
provider.
The feature includes several changes that are not directly related to the
electricity price prediction implementation but are necessary to keep
EOS running properly and to test and document the changes.
* feat: add value time windows
Add time windows with an associated float value.
* feat: harden eos measurements endpoints error detection and reporting
Cover more errors that may be raised during endpoint access. Report the
errors including trace information to ease debugging.
* feat: extend server configuration to cover all arguments
Make the argument controlled options also available in server configuration.
* fix: eos config configuration by cli arguments
Move the command line argument handling to config eos so that it is
excuted whenever eos config is rebuild or reset.
* chore: extend measurement endpoint system test
* chore: refactor time windows
Move time windows to configabc as they are only used in configurations.
Also move all tests to test_configabc.
* chore: provide config update errors in eosdash with summarized error text
If there is an update error provide the error text as a summary. On click
provide the full error text.
* chore: force eosdash ip address and port in makefile dev run
Ensure eosdash ip address and port are correctly set for development runs.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Validate solution prediction data before processing.
If required prediction data is missing, the prediction is skipped
instead of raising an exception.
Introduce a new configuration file saving policy to improve loading robustness:
- Exclude computed fields
- Exclude fields set to their default values
- Exclude fields with value None
- Use field aliases
- Recursively remove empty dictionaries and lists
- Ensure general.version is always present and correctly set
When loading older configuration files, computed fields are now stripped
before migration. This further improves backward compatibility and loading
robustness.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Adapt uvicorn log level to allowed levels.
Ensure that EOSdash is started after EOS configuration is available.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
* fix: improve error handling for provider updates
Distinguishes failures of active providers from inactive ones.
Propagates errors only for enabled providers, allowing execution
to continue if a non-active provider fails, which avoids unnecessary
interruptions and improves robustness.
* fix: add provider settings validation for forecast requests
Prevents potential runtime errors by checking if provider settings are configured
before accessing forecast credentials.
Raises a clear error when settings are missing to help with debugging misconfigurations.
* refactor(load): move provider settings to top-level fields
Transitions load provider settings from a nested "provider_settings" object with provider-specific keys to dedicated top-level fields.\n\nRemoves the legacy "provider_settings" mapping and updates migration logic to ensure backward compatibility with existing configurations.
* docs: update version numbers and documantation
---------
Co-authored-by: Normann <github@koldrack.com>
Startup retention manager for asynchronous tasks. Handle gracefully
exceptions in these tasks or the configuration for them.
Remove tasks.py as repeated tasks are now handled by the retention
manager.
When running on GitHub, only the version date file is checked. The
development tag is merely a label, so any date set during development suffices.
The test_doc is also skipped on GitHub actions.
Ensure that the snapping sequence generated in the test fixture
is within the boundaries expected by the test.
Ensure we read the _version_date.py info as UTC datetime and do
no localtime conversion.
Prevent and guard test_version.py to modify the version date file.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Upgrade to:
- pandas==3.01
- fastapi[standard-no-fastapi-cloud-cli]==0.132.0
- fastapi_cli==0.0.23
- MonsterUI==1.0.44
- uvicorn==0.41.0
Close database in database fixture on teardown.
Fix file exclusion in hash and version date generation.
Update version information in documentation.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Home Assistant expects versioning always increases numbers. Add
a date component to the development version to comply with this
expectation. The scheme is now 0.0.0.dev<date><hash>.
Use uv for creating and managing the virtual environment for developement.
This enourmously speeds up dependency updates. For this change
dependency requirements are now solely handled in pyproject.toml.
requirements.tx and requirements-dev.txt are deleted.
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
The database supports backend selection, compression, incremental data load,
automatic data saving to storage, automatic vaccum and compaction.
Make SQLite3 and LMDB database backends available.
Update tests for new interface conventions regarding data sequences,
data containers, data providers. This includes the measurements provider and
the prediction providers.
Add database documentation.
The fix includes several bug fixes that are not directly related to the database
implementation but are necessary to keep EOS running properly and to test and
document the changes.
* fix: config eos test setup
Make the config_eos fixture generate a new instance of the config_eos singleton.
Use correct env names to setup data folder path.
* fix: startup with no config
Make cache and measurements complain about missing data path configuration but
do not bail out.
* fix: soc data preparation and usage for genetic optimization.
Search for soc measurments 48 hours around the optimization start time.
Only clamp soc to maximum in battery device simulation.
* fix: dashboard bailout on zero value solution display
Do not use zero values to calculate the chart values adjustment for display.
* fix: openapi generation script
Make the script also replace data_folder_path and data_output_path to hide
real (test) environment pathes.
* feat: add make repeated task function
make_repeated_task allows to wrap a function to be repeated cyclically.
* chore: removed index based data sequence access
Index based data sequence access does not make sense as the sequence can be backed
by the database. The sequence is now purely time series data.
* chore: refactor eos startup to avoid module import startup
Avoid module import initialisation expecially of the EOS configuration.
Config mutation, singleton initialization, logging setup, argparse parsing,
background task definitions depending on config and environment-dependent behavior
is now done at function startup.
* chore: introduce retention manager
A single long-running background task that owns the scheduling of all periodic
server-maintenance jobs (cache cleanup, DB autosave, …)
* chore: canonicalize timezone name for UTC
Timezone names that are semantically identical to UTC are canonicalized to UTC.
* chore: extend config file migration for default value handling
Extend the config file migration handling values None or nonexisting values
that will invoke a default value generation in the new config file. Also
adapt test to handle this situation.
* chore: extend datetime util test cases
* chore: make version test check for untracked files
Check for files that are not tracked by git. Version calculation will be
wrong if these files will not be commited.
* chore: bump pandas to 3.0.0
Pandas 3.0 now performs inference on the appropriate resolution (a.k.a. unit)
for the output dtype which may become datetime64[us] (before it was ns). Also
numeric dtype detection is now more strict which needs a different detection for
numerics.
* chore: bump pydantic-settings to 2.12.0
pydantic-settings 2.12.0 under pytest creates a different behaviour. The tests
were adapted and a workaround was introduced. Also ConfigEOS was adapted
to allow for fine grain initialization control to be able to switch
off certain settings such as file settings during test.
* chore: remove sci learn kit from dependencies
The sci learn kit is not strictly necessary as long as we have scipy.
* chore: add documentation mode guarding for sphinx autosummary
Sphinx autosummary excecutes functions. Prevent exceptions in case of pure doc
mode.
* chore: adapt docker-build CI workflow to stricter GitHub handling
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>