Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration branch for FastAPI and other PRs #177

Closed
wants to merge 25 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e3c756
Migrate from Flask to FastAPI
Lasall Oct 10, 2024
8458684
Move API doc from README to pydantic model classes (swagger)
Lasall Oct 12, 2024
2277d1f
Add package API documentation generation
b0661 Oct 10, 2024
a1cef1e
Enable Google style source commenting and documentation generation.
b0661 Oct 11, 2024
882aae6
Check Google style source commenting.
b0661 Oct 11, 2024
906c652
Add settings and extension recommendations
Oct 11, 2024
f6e8ada
Add pyright section for pylance extension
Oct 11, 2024
6d09e44
Enable pytest and debugging
Oct 11, 2024
53905cb
Prettier files
Oct 11, 2024
685e855
Bump sphinx from 8.0.2 to 8.1.3
dependabot[bot] Oct 14, 2024
7ab9314
Merge branch 'pr_int_fastapi-rebase-pr-163' into pr_int_fastapi
b0661 Oct 19, 2024
1f50eb5
test_load_corrector
NormannK Oct 10, 2024
e08e2b5
Streamline Dockerfile, remove unused deps
Lasall Oct 7, 2024
0923584
Ruff format
Oct 10, 2024
7763b1f
rebase fixes
NormannK Oct 11, 2024
2952cda
ruff changes
NormannK Oct 11, 2024
676b4d8
Cleanup: Fix violin chart labels, remove debug code
Lasall Oct 11, 2024
1f0ee74
Merge branch 'pr_int_fastapi-rebase-pr-172' into pr_int_fastapi
b0661 Oct 19, 2024
4186937
Add documentation to class_pv_forecast.py.
b0661 Oct 11, 2024
1fbdd18
Add CacheFileStore, to_datetime and get_logger utilities.
b0661 Oct 15, 2024
d38b24a
Improve testability of PVForecast
b0661 Oct 12, 2024
7ad1eea
Add test for PVForecast and newly extracted utility modules.
b0661 Oct 12, 2024
ba52724
Merge branch 'pr_int_fastapi-rebase-pr-174' into pr_int_fastapi
b0661 Oct 19, 2024
1f5abf3
Tool to integrate EOS PRs in an integration branch.
b0661 Oct 19, 2024
14a1be6
Merge branch 'pr_int_fastapi-rebase-pr-176' into pr_int_fastapi
b0661 Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prettier files
Chris authored and b0661 committed Oct 19, 2024
commit 53905cb552d94bc1105fbbcac193cc7ad9634578
42 changes: 21 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Exclude some file types from automatic code style
exclude: \.(json|csv)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
# Run the linter and fix simple issues automatically
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
# Run the linter and fix simple issues automatically
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
250 changes: 249 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ To always use the Python version from the virtual environment, you should activa
```bash
source .venv/bin/activate
```

(for Bash users, the default under Linux) or

```zsh
@@ -93,7 +94,254 @@ These classes work together to enable a detailed simulation and optimization of

Each class is designed to be easily customized and extended to integrate additional functions or improvements. For example, new methods can be added for more accurate modeling of PV system or battery behavior. Developers are invited to modify and extend the system according to their needs.


# Server API

See the Swagger documentation for detailed information: [EOS OpenAPI Spec](https://petstore3.swagger.io/?url=https://raw.githubusercontent.com/Akkudoktor-EOS/EOS/refs/heads/main/openapi.json)

# Input for the FastAPI Server (as of 30.07.2024)

Describes the structure and data types of the JSON object sent to the Flask server, with a forecast period of 48 hours.

## JSON Object Fields

### `strompreis_euro_pro_wh`

- **Description**: An array of floats representing the electricity price in euros per watt-hour for different time intervals.
- **Type**: Array
- **Element Type**: Float
- **Length**: 48

### `gesamtlast`

- **Description**: An array of floats representing the total load (consumption) in watts for different time intervals.
- **Type**: Array
- **Element Type**: Float
- **Length**: 48

### `pv_forecast`

- **Description**: An array of floats representing the forecasted photovoltaic output in watts for different time intervals.
- **Type**: Array
- **Element Type**: Float
- **Length**: 48

### `temperature_forecast`

- **Description**: An array of floats representing the temperature forecast in degrees Celsius for different time intervals.
- **Type**: Array
- **Element Type**: Float
- **Length**: 48

### `pv_soc`

- **Description**: An integer representing the state of charge of the PV battery at the **start** of the current hour (not the current state).
- **Type**: Integer

### `pv_akku_cap`

- **Description**: An integer representing the capacity of the photovoltaic battery in watt-hours.
- **Type**: Integer

### `einspeiseverguetung_euro_pro_wh`

- **Description**: A float representing the feed-in compensation in euros per watt-hour.
- **Type**: Float

### `eauto_min_soc`

- **Description**: An integer representing the minimum state of charge (SOC) of the electric vehicle in percentage.
- **Type**: Integer

### `eauto_cap`

- **Description**: An integer representing the capacity of the electric vehicle battery in watt-hours.
- **Type**: Integer

### `eauto_charge_efficiency`

- **Description**: A float representing the charging efficiency of the electric vehicle.
- **Type**: Float

### `eauto_charge_power`

- **Description**: An integer representing the charging power of the electric vehicle in watts.
- **Type**: Integer

### `eauto_soc`

- **Description**: An integer representing the current state of charge (SOC) of the electric vehicle in percentage.
- **Type**: Integer

### `start_solution`

- **Description**: Can be `null` or contain a previous solution (if available).
- **Type**: `null` or object

### `haushaltsgeraet_wh`

- **Description**: An integer representing the energy consumption of a household device in watt-hours.
- **Type**: Integer

### `haushaltsgeraet_dauer`

- **Description**: An integer representing the usage duration of a household device in hours.
- **Type**: Integer

# JSON Output Description

This document describes the structure and data types of the JSON output returned by the Flask server, with a forecast period of 48 hours.

**Note**: The first value of "Last_Wh_pro_Stunde", "Netzeinspeisung_Wh_pro_Stunde" and "Netzbezug_Wh_pro_Stunde", will be set to null in the JSON output and represented as NaN or None in the corresponding classes' data returns. This approach is adopted to ensure that the current hour's processing remains unchanged.

## JSON Output Fields (as of 30.7.2024)

### discharge_hours_bin

An array that indicates for each hour of the forecast period (in this example, 48 hours) whether energy is discharged from the battery or not. The values are either `0` (no discharge) or `1` (discharge).

### eauto_obj

This object contains information related to the electric vehicle and its charging and discharging behavior:

- **charge_array**: Indicates for each hour whether the EV is charging (`0` for no charging, `1` for charging).
- **Type**: Array
- **Element Type**: Integer (0 or 1)
- **Length**: 48
- **discharge_array**: Indicates for each hour whether the EV is discharging (`0` for no discharging, `1` for discharging).
- **Type**: Array
- **Element Type**: Integer (0 or 1)
- **Length**: 48
- **entlade_effizienz**: The discharge efficiency as a float.
- **Type**: Float
- **hours**: Amount of hours the simulation is done for.
- **Type**: Integer
- **kapazitaet_wh**: The capacity of the EV’s battery in watt-hours.
- **Type**: Integer
- **lade_effizienz**: The charging efficiency as a float.
- **Type**: Float
- **max_ladeleistung_w**: The maximum charging power of the EV in watts.
- **Type**: Float
- **max_ladeleistung_w**: Max charging power of the EV in Watts.
- **Type**: Integer
- **soc_wh**: The state of charge of the battery in watt-hours at the start of the simulation.
- **Type**: Integer
- **start_soc_prozent**: The state of charge of the battery in percentage at the start of the simulation.
- **Type**: Integer

### eautocharge_hours_float

An array of binary values (0 or 1) that indicates whether the EV will be charged in a certain hour.

- **Type**: Array
- **Element Type**: Integer (0 or 1)
- **Length**: 48

### result

This object contains the results of the simulation and provides insights into various parameters over the entire forecast period:

- **E-Auto_SoC_pro_Stunde**: The state of charge of the EV for each hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Eigenverbrauch_Wh_pro_Stunde**: The self-consumption of the system in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Einnahmen_Euro_pro_Stunde**: The revenue from grid feed-in or other sources in euros per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Gesamt_Verluste**: The total losses in watt-hours over the entire period.
- **Type**: Float
- **Gesamtbilanz_Euro**: The total balance of revenues minus costs in euros.
- **Type**: Float
- **Gesamteinnahmen_Euro**: The total revenues in euros.
- **Type**: Float
- **Gesamtkosten_Euro**: The total costs in euros.
- **Type**: Float
- **Haushaltsgeraet_wh_pro_stunde**: The energy consumption of a household appliance in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Kosten_Euro_pro_Stunde**: The costs in euros per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Netzbezug_Wh_pro_Stunde**: The grid energy drawn in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Netzeinspeisung_Wh_pro_Stunde**: The energy fed into the grid in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Verluste_Pro_Stunde**: The losses in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **akku_soc_pro_stunde**: The state of charge of the battery (not the EV) in percentage per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35

### simulation_data

An object containing the simulated data.

- **E-Auto_SoC_pro_Stunde**: An array of floats representing the simulated state of charge of the electric car per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Eigenverbrauch_Wh_pro_Stunde**: An array of floats representing the simulated self-consumption in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Einnahmen_Euro_pro_Stunde**: An array of floats representing the simulated income in euros per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Gesamt_Verluste**: The total simulated losses in watt-hours.
- **Type**: Float
- **Gesamtbilanz_Euro**: The total simulated balance in euros.
- **Type**: Float
- **Gesamteinnahmen_Euro**: The total simulated income in euros.
- **Type**: Float
- **Gesamtkosten_Euro**: The total simulated costs in euros.
- **Type**: Float
- **Haushaltsgeraet_wh_pro_stunde**: An array of floats representing the simulated energy consumption of a household appliance in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Kosten_Euro_pro_Stunde**: An array of floats representing the simulated costs in euros per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Netzbezug_Wh_pro_Stunde**: An array of floats representing the simulated grid consumption in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Netzeinspeisung_Wh_pro_Stunde**: An array of floats representing the simulated grid feed-in in watt-hours per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **Verluste_Pro_Stunde**: An array of floats representing the simulated losses per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35
- **akku_soc_pro_stunde**: An array of floats representing the simulated state of charge of the battery in percentage per hour.
- **Type**: Array
- **Element Type**: Float
- **Length**: 35

### spuelstart

- **Description**: Can be `null` or contain an object representing the start of washing (if applicable).
- **Type**: null or object

### start_solution

- **Description**: An array of binary values (0 or 1) representing a possible starting solution for the simulation.
- **Type**: Array
- **Element Type**: Integer (0 or 1)
- **Length**: 48
14 changes: 7 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
networks:
eos:
name: 'eos'
name: "eos"
services:
eos:
image: 'akkudoktor/eos:${EOS_VERSION}'
image: "akkudoktor/eos:${EOS_VERSION}"
read_only: true
build:
context: .
dockerfile: 'Dockerfile'
dockerfile: "Dockerfile"
args:
PYTHON_VERSION: '${PYTHON_VERSION}'
PYTHON_VERSION: "${PYTHON_VERSION}"
init: true
environment:
FLASK_RUN_PORT: '${EOS_PORT}'
FLASK_RUN_PORT: "${EOS_PORT}"
networks:
- 'eos'
- "eos"
volumes:
- ./src/akkudoktoreos/config.py:/opt/eos/akkudoktoreos/config.py:ro
ports:
- '${EOS_PORT}:${EOS_PORT}'
- "${EOS_PORT}:${EOS_PORT}"