Skip to content

Commit 04420e6

Browse files
cnadler86NormannK
andauthored
fix: Improve provider update error handling and add VRM provider settings validation (Akkudoktor-EOS#887)
* 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>
1 parent 2ca9c93 commit 04420e6

20 files changed

Lines changed: 148 additions & 240 deletions

docs/_generated/configexample.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,24 @@
120120
}
121121
},
122122
"general": {
123-
"version": "0.2.0.dev2602242106748274",
123+
"version": "0.2.0.dev2602250574650225",
124124
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
125125
"data_output_subpath": "output",
126126
"latitude": 52.52,
127127
"longitude": 13.405
128128
},
129129
"load": {
130130
"provider": "LoadAkkudoktor",
131-
"provider_settings": {
132-
"LoadAkkudoktor": null,
133-
"LoadVrm": null,
134-
"LoadImport": null
131+
"loadakkudoktor": {
132+
"loadakkudoktor_year_energy_kwh": null
133+
},
134+
"loadvrm": {
135+
"load_vrm_token": "your-token",
136+
"load_vrm_idsite": 12345
137+
},
138+
"loadimport": {
139+
"import_file_path": null,
140+
"import_json": null
135141
}
136142
},
137143
"logging": {

docs/_generated/configgeneral.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| latitude | `EOS_GENERAL__LATITUDE` | `Optional[float]` | `rw` | `52.52` | Latitude in decimal degrees between -90 and 90. North is positive (ISO 19115) (°) |
1717
| longitude | `EOS_GENERAL__LONGITUDE` | `Optional[float]` | `rw` | `13.405` | Longitude in decimal degrees within -180 to 180 (°) |
1818
| timezone | | `Optional[str]` | `ro` | `N/A` | Computed timezone based on latitude and longitude. |
19-
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev2602242106748274` | Configuration file version. Used to check compatibility. |
19+
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0.dev2602250574650225` | Configuration file version. Used to check compatibility. |
2020
:::
2121
<!-- pyml enable line-length -->
2222

@@ -28,7 +28,7 @@
2828
```json
2929
{
3030
"general": {
31-
"version": "0.2.0.dev2602242106748274",
31+
"version": "0.2.0.dev2602250574650225",
3232
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
3333
"data_output_subpath": "output",
3434
"latitude": 52.52,
@@ -46,7 +46,7 @@
4646
```json
4747
{
4848
"general": {
49-
"version": "0.2.0.dev2602242106748274",
49+
"version": "0.2.0.dev2602250574650225",
5050
"data_folder_path": "/home/user/.local/share/net.akkudoktoreos.net",
5151
"data_output_subpath": "output",
5252
"latitude": 52.52,

docs/_generated/configload.md

Lines changed: 39 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
| Name | Environment Variable | Type | Read-Only | Default | Description |
99
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
10+
| loadakkudoktor | `EOS_LOAD__LOADAKKUDOKTOR` | `LoadAkkudoktorCommonSettings` | `rw` | `required` | LoadAkkudoktor provider settings. |
11+
| loadimport | `EOS_LOAD__LOADIMPORT` | `LoadImportCommonSettings` | `rw` | `required` | LoadImport provider settings. |
12+
| loadvrm | `EOS_LOAD__LOADVRM` | `LoadVrmCommonSettings` | `rw` | `required` | LoadVrm provider settings. |
1013
| provider | `EOS_LOAD__PROVIDER` | `Optional[str]` | `rw` | `None` | Load provider id of provider to be used. |
11-
| provider_settings | `EOS_LOAD__PROVIDER_SETTINGS` | `LoadCommonProviderSettings` | `rw` | `required` | Provider settings |
1214
| providers | | `list[str]` | `ro` | `N/A` | Available load provider ids. |
1315
:::
1416
<!-- pyml enable line-length -->
@@ -22,10 +24,16 @@
2224
{
2325
"load": {
2426
"provider": "LoadAkkudoktor",
25-
"provider_settings": {
26-
"LoadAkkudoktor": null,
27-
"LoadVrm": null,
28-
"LoadImport": null
27+
"loadakkudoktor": {
28+
"loadakkudoktor_year_energy_kwh": null
29+
},
30+
"loadvrm": {
31+
"load_vrm_token": "your-token",
32+
"load_vrm_idsite": 12345
33+
},
34+
"loadimport": {
35+
"import_file_path": null,
36+
"import_json": null
2937
}
3038
}
3139
}
@@ -41,10 +49,16 @@
4149
{
4250
"load": {
4351
"provider": "LoadAkkudoktor",
44-
"provider_settings": {
45-
"LoadAkkudoktor": null,
46-
"LoadVrm": null,
47-
"LoadImport": null
52+
"loadakkudoktor": {
53+
"loadakkudoktor_year_energy_kwh": null
54+
},
55+
"loadvrm": {
56+
"load_vrm_token": "your-token",
57+
"load_vrm_idsite": 12345
58+
},
59+
"loadimport": {
60+
"import_file_path": null,
61+
"import_json": null
4862
},
4963
"providers": [
5064
"LoadAkkudoktor",
@@ -57,43 +71,10 @@
5771
```
5872
<!-- pyml enable line-length -->
5973

60-
### Common settings for load data import from file or JSON string
61-
62-
<!-- pyml disable line-length -->
63-
:::{table} load::provider_settings::LoadImport
64-
:widths: 10 10 5 5 30
65-
:align: left
66-
67-
| Name | Type | Read-Only | Default | Description |
68-
| ---- | ---- | --------- | ------- | ----------- |
69-
| import_file_path | `Union[str, pathlib.Path, NoneType]` | `rw` | `None` | Path to the file to import load data from. |
70-
| import_json | `Optional[str]` | `rw` | `None` | JSON string, dictionary of load forecast value lists. |
71-
:::
72-
<!-- pyml enable line-length -->
73-
74-
<!-- pyml disable no-emphasis-as-heading -->
75-
**Example Input/Output**
76-
<!-- pyml enable no-emphasis-as-heading -->
77-
78-
<!-- pyml disable line-length -->
79-
```json
80-
{
81-
"load": {
82-
"provider_settings": {
83-
"LoadImport": {
84-
"import_file_path": null,
85-
"import_json": "{\"load0_mean\": [676.71, 876.19, 527.13]}"
86-
}
87-
}
88-
}
89-
}
90-
```
91-
<!-- pyml enable line-length -->
92-
9374
### Common settings for load forecast VRM API
9475

9576
<!-- pyml disable line-length -->
96-
:::{table} load::provider_settings::LoadVrm
77+
:::{table} load::loadvrm
9778
:widths: 10 10 5 5 30
9879
:align: left
9980

@@ -112,27 +93,26 @@
11293
```json
11394
{
11495
"load": {
115-
"provider_settings": {
116-
"LoadVrm": {
117-
"load_vrm_token": "your-token",
118-
"load_vrm_idsite": 12345
119-
}
96+
"loadvrm": {
97+
"load_vrm_token": "your-token",
98+
"load_vrm_idsite": 12345
12099
}
121100
}
122101
}
123102
```
124103
<!-- pyml enable line-length -->
125104

126-
### Common settings for load data import from file
105+
### Common settings for load data import from file or JSON string
127106

128107
<!-- pyml disable line-length -->
129-
:::{table} load::provider_settings::LoadAkkudoktor
108+
:::{table} load::loadimport
130109
:widths: 10 10 5 5 30
131110
:align: left
132111

133112
| Name | Type | Read-Only | Default | Description |
134113
| ---- | ---- | --------- | ------- | ----------- |
135-
| loadakkudoktor_year_energy_kwh | `Optional[float]` | `rw` | `None` | Yearly energy consumption (kWh). |
114+
| import_file_path | `Union[str, pathlib.Path, NoneType]` | `rw` | `None` | Path to the file to import load data from. |
115+
| import_json | `Optional[str]` | `rw` | `None` | JSON string, dictionary of load forecast value lists. |
136116
:::
137117
<!-- pyml enable line-length -->
138118

@@ -144,28 +124,25 @@
144124
```json
145125
{
146126
"load": {
147-
"provider_settings": {
148-
"LoadAkkudoktor": {
149-
"loadakkudoktor_year_energy_kwh": 40421.0
150-
}
127+
"loadimport": {
128+
"import_file_path": null,
129+
"import_json": "{\"load0_mean\": [676.71, 876.19, 527.13]}"
151130
}
152131
}
153132
}
154133
```
155134
<!-- pyml enable line-length -->
156135

157-
### Load Prediction Provider Configuration
136+
### Common settings for load data import from file
158137

159138
<!-- pyml disable line-length -->
160-
:::{table} load::provider_settings
139+
:::{table} load::loadakkudoktor
161140
:widths: 10 10 5 5 30
162141
:align: left
163142

164143
| Name | Type | Read-Only | Default | Description |
165144
| ---- | ---- | --------- | ------- | ----------- |
166-
| LoadAkkudoktor | `Optional[akkudoktoreos.prediction.loadakkudoktor.LoadAkkudoktorCommonSettings]` | `rw` | `None` | LoadAkkudoktor settings |
167-
| LoadImport | `Optional[akkudoktoreos.prediction.loadimport.LoadImportCommonSettings]` | `rw` | `None` | LoadImport settings |
168-
| LoadVrm | `Optional[akkudoktoreos.prediction.loadvrm.LoadVrmCommonSettings]` | `rw` | `None` | LoadVrm settings |
145+
| loadakkudoktor_year_energy_kwh | `Optional[float]` | `rw` | `None` | Yearly energy consumption (kWh). |
169146
:::
170147
<!-- pyml enable line-length -->
171148

@@ -177,10 +154,8 @@
177154
```json
178155
{
179156
"load": {
180-
"provider_settings": {
181-
"LoadAkkudoktor": null,
182-
"LoadVrm": null,
183-
"LoadImport": null
157+
"loadakkudoktor": {
158+
"loadakkudoktor_year_energy_kwh": 40421.0
184159
}
185160
}
186161
}

docs/_generated/openapi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Akkudoktor-EOS
22

3-
**Version**: `v0.2.0.dev2602242106748274`
3+
**Version**: `v0.2.0.dev2602250574650225`
44

55
<!-- pyml disable line-length -->
66
**Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.

openapi.json

Lines changed: 25 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "Apache 2.0",
99
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
1010
},
11-
"version": "v0.2.0.dev2602242106748274"
11+
"version": "v0.2.0.dev2602250574650225"
1212
},
1313
"paths": {
1414
"/v1/admin/cache/clear": {
@@ -4451,7 +4451,7 @@
44514451
"type": "string",
44524452
"title": "Version",
44534453
"description": "Configuration file version. Used to check compatibility.",
4454-
"default": "0.2.0.dev2602242106748274"
4454+
"default": "0.2.0.dev2602250574650225"
44554455
},
44564456
"data_folder_path": {
44574457
"type": "string",
@@ -4514,7 +4514,7 @@
45144514
"type": "string",
45154515
"title": "Version",
45164516
"description": "Configuration file version. Used to check compatibility.",
4517-
"default": "0.2.0.dev2602242106748274"
4517+
"default": "0.2.0.dev2602250574650225"
45184518
},
45194519
"data_folder_path": {
45204520
"type": "string",
@@ -5942,55 +5942,6 @@
59425942
"title": "LoadAkkudoktorCommonSettings",
59435943
"description": "Common settings for load data import from file."
59445944
},
5945-
"LoadCommonProviderSettings": {
5946-
"properties": {
5947-
"LoadAkkudoktor": {
5948-
"anyOf": [
5949-
{
5950-
"$ref": "#/components/schemas/LoadAkkudoktorCommonSettings"
5951-
},
5952-
{
5953-
"type": "null"
5954-
}
5955-
],
5956-
"description": "LoadAkkudoktor settings",
5957-
"examples": [
5958-
null
5959-
]
5960-
},
5961-
"LoadVrm": {
5962-
"anyOf": [
5963-
{
5964-
"$ref": "#/components/schemas/LoadVrmCommonSettings"
5965-
},
5966-
{
5967-
"type": "null"
5968-
}
5969-
],
5970-
"description": "LoadVrm settings",
5971-
"examples": [
5972-
null
5973-
]
5974-
},
5975-
"LoadImport": {
5976-
"anyOf": [
5977-
{
5978-
"$ref": "#/components/schemas/LoadImportCommonSettings"
5979-
},
5980-
{
5981-
"type": "null"
5982-
}
5983-
],
5984-
"description": "LoadImport settings",
5985-
"examples": [
5986-
null
5987-
]
5988-
}
5989-
},
5990-
"type": "object",
5991-
"title": "LoadCommonProviderSettings",
5992-
"description": "Load Prediction Provider Configuration."
5993-
},
59945945
"LoadCommonSettings-Input": {
59955946
"properties": {
59965947
"provider": {
@@ -6008,12 +5959,17 @@
60085959
"LoadAkkudoktor"
60095960
]
60105961
},
6011-
"provider_settings": {
6012-
"$ref": "#/components/schemas/LoadCommonProviderSettings",
6013-
"description": "Provider settings",
6014-
"examples": [
6015-
{}
6016-
]
5962+
"loadakkudoktor": {
5963+
"$ref": "#/components/schemas/LoadAkkudoktorCommonSettings",
5964+
"description": "LoadAkkudoktor provider settings."
5965+
},
5966+
"loadvrm": {
5967+
"$ref": "#/components/schemas/LoadVrmCommonSettings",
5968+
"description": "LoadVrm provider settings."
5969+
},
5970+
"loadimport": {
5971+
"$ref": "#/components/schemas/LoadImportCommonSettings",
5972+
"description": "LoadImport provider settings."
60175973
}
60185974
},
60195975
"type": "object",
@@ -6037,12 +5993,17 @@
60375993
"LoadAkkudoktor"
60385994
]
60395995
},
6040-
"provider_settings": {
6041-
"$ref": "#/components/schemas/LoadCommonProviderSettings",
6042-
"description": "Provider settings",
6043-
"examples": [
6044-
{}
6045-
]
5996+
"loadakkudoktor": {
5997+
"$ref": "#/components/schemas/LoadAkkudoktorCommonSettings",
5998+
"description": "LoadAkkudoktor provider settings."
5999+
},
6000+
"loadvrm": {
6001+
"$ref": "#/components/schemas/LoadVrmCommonSettings",
6002+
"description": "LoadVrm provider settings."
6003+
},
6004+
"loadimport": {
6005+
"$ref": "#/components/schemas/LoadImportCommonSettings",
6006+
"description": "LoadImport provider settings."
60466007
},
60476008
"providers": {
60486009
"items": {
@@ -8785,13 +8746,6 @@
87858746
"type": {
87868747
"type": "string",
87878748
"title": "Error Type"
8788-
},
8789-
"input": {
8790-
"title": "Input"
8791-
},
8792-
"ctx": {
8793-
"type": "object",
8794-
"title": "Context"
87958749
}
87968750
},
87978751
"type": "object",

0 commit comments

Comments
 (0)