mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-10-31 23:06:20 +00:00
fix: ensure EV charge rates settings available
Some checks failed
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Some checks failed
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Allow charge rates for electric vehicle to be provided by the POST optimize endpoint. Create a default value in case neither the parameters nor the configuration provide charge rates. This is also to allow to migrate from 0.1.0 configuration format to actual one. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -602,7 +602,7 @@ Properties:
|
|||||||
| max_charge_power_w | `Optional[float]` | `rw` | `5000` | Maximum charging power [W]. |
|
| max_charge_power_w | `Optional[float]` | `rw` | `5000` | Maximum charging power [W]. |
|
||||||
| min_charge_power_w | `Optional[float]` | `rw` | `50` | Minimum charging power [W]. |
|
| min_charge_power_w | `Optional[float]` | `rw` | `50` | Minimum charging power [W]. |
|
||||||
| charge_rates | `Optional[list[float]]` | `rw` | `None` | Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available. |
|
| charge_rates | `Optional[list[float]]` | `rw` | `None` | Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available. |
|
||||||
| min_soc_percentage | `int` | `rw` | `0` | Minimum state of charge (SOC) as percentage of capacity [%]. |
|
| min_soc_percentage | `int` | `rw` | `0` | Minimum state of charge (SOC) as percentage of capacity [%]. This is the target SoC for charging |
|
||||||
| max_soc_percentage | `int` | `rw` | `100` | Maximum state of charge (SOC) as percentage of capacity [%]. |
|
| max_soc_percentage | `int` | `rw` | `100` | Maximum state of charge (SOC) as percentage of capacity [%]. |
|
||||||
| measurement_key_soc_factor | `str` | `ro` | `N/A` | Measurement key for the battery state of charge (SoC) as factor of total capacity [0.0 ... 1.0]. |
|
| measurement_key_soc_factor | `str` | `ro` | `N/A` | Measurement key for the battery state of charge (SoC) as factor of total capacity [0.0 ... 1.0]. |
|
||||||
| measurement_key_power_l1_w | `str` | `ro` | `N/A` | Measurement key for the L1 power the battery is charged or discharged with [W]. |
|
| measurement_key_power_l1_w | `str` | `ro` | `N/A` | Measurement key for the L1 power the battery is charged or discharged with [W]. |
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ passed to the request. You have to set the parameters even if given in the confi
|
|||||||
"device_id": "ev1",
|
"device_id": "ev1",
|
||||||
"capacity_wh": 60000,
|
"capacity_wh": 60000,
|
||||||
"charging_efficiency": 0.95,
|
"charging_efficiency": 0.95,
|
||||||
|
"charge_rates": [0.0, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0],
|
||||||
"discharging_efficiency": 1.0,
|
"discharging_efficiency": 1.0,
|
||||||
"max_charge_power_w": 11040,
|
"max_charge_power_w": 11040,
|
||||||
"initial_soc_percentage": 54,
|
"initial_soc_percentage": 54,
|
||||||
|
|||||||
29
openapi.json
29
openapi.json
@@ -2067,7 +2067,7 @@
|
|||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"minimum": 0.0,
|
"minimum": 0.0,
|
||||||
"title": "Min Soc Percentage",
|
"title": "Min Soc Percentage",
|
||||||
"description": "Minimum state of charge (SOC) as percentage of capacity [%].",
|
"description": "Minimum state of charge (SOC) as percentage of capacity [%]. This is the target SoC for charging",
|
||||||
"default": 0,
|
"default": 0,
|
||||||
"examples": [
|
"examples": [
|
||||||
10
|
10
|
||||||
@@ -2208,7 +2208,7 @@
|
|||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"minimum": 0.0,
|
"minimum": 0.0,
|
||||||
"title": "Min Soc Percentage",
|
"title": "Min Soc Percentage",
|
||||||
"description": "Minimum state of charge (SOC) as percentage of capacity [%].",
|
"description": "Minimum state of charge (SOC) as percentage of capacity [%]. This is the target SoC for charging",
|
||||||
"default": 0,
|
"default": 0,
|
||||||
"examples": [
|
"examples": [
|
||||||
10
|
10
|
||||||
@@ -3184,6 +3184,31 @@
|
|||||||
"title": "Max Soc Percentage",
|
"title": "Max Soc Percentage",
|
||||||
"description": "An integer representing the maximum state of charge (SOC) of the battery in percentage.",
|
"description": "An integer representing the maximum state of charge (SOC) of the battery in percentage.",
|
||||||
"default": 100
|
"default": 100
|
||||||
|
},
|
||||||
|
"charge_rates": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Charge Rates",
|
||||||
|
"description": "Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available.",
|
||||||
|
"examples": [
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
0.25,
|
||||||
|
0.5,
|
||||||
|
0.75,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
null
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class BatteriesCommonSettings(DevicesBaseSettings):
|
|||||||
default=0,
|
default=0,
|
||||||
ge=0,
|
ge=0,
|
||||||
le=100,
|
le=100,
|
||||||
description="Minimum state of charge (SOC) as percentage of capacity [%].",
|
description="Minimum state of charge (SOC) as percentage of capacity [%]. This is the target SoC for charging",
|
||||||
examples=[10],
|
examples=[10],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -837,15 +837,33 @@ class GeneticOptimization(OptimizationBase):
|
|||||||
self.optimize_ev = (
|
self.optimize_ev = (
|
||||||
parameters.eauto.min_soc_percentage - parameters.eauto.initial_soc_percentage >= 0
|
parameters.eauto.min_soc_percentage - parameters.eauto.initial_soc_percentage >= 0
|
||||||
)
|
)
|
||||||
try:
|
# electrical vehicle charge rates
|
||||||
charge_rates = self.config.devices.electric_vehicles[0].charge_rates
|
if parameters.eauto.charge_rates is not None:
|
||||||
if charge_rates is None:
|
self.ev_possible_charge_values = parameters.eauto.charge_rates
|
||||||
raise
|
elif (
|
||||||
except:
|
self.config.devices.electric_vehicles
|
||||||
error_msg = "No charge rates provided for electric vehicle."
|
and self.config.devices.electric_vehicles[0]
|
||||||
logger.exception(error_msg)
|
and self.config.devices.electric_vehicles[0].charge_rates is not None
|
||||||
raise ValueError(error_msg)
|
):
|
||||||
self.ev_possible_charge_values = charge_rates
|
self.ev_possible_charge_values = self.config.devices.electric_vehicles[
|
||||||
|
0
|
||||||
|
].charge_rates
|
||||||
|
else:
|
||||||
|
warning_msg = "No charge rates provided for electric vehicle - using default."
|
||||||
|
logger.warning(warning_msg)
|
||||||
|
self.ev_possible_charge_values = [
|
||||||
|
0.0,
|
||||||
|
0.1,
|
||||||
|
0.2,
|
||||||
|
0.3,
|
||||||
|
0.4,
|
||||||
|
0.5,
|
||||||
|
0.6,
|
||||||
|
0.7,
|
||||||
|
0.8,
|
||||||
|
0.9,
|
||||||
|
1.0,
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
self.optimize_ev = False
|
self.optimize_ev = False
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,11 @@ class ElectricVehicleParameters(BaseBatteryParameters):
|
|||||||
initial_soc_percentage: int = initial_soc_percentage_field(
|
initial_soc_percentage: int = initial_soc_percentage_field(
|
||||||
"An integer representing the current state of charge (SOC) of the battery in percentage."
|
"An integer representing the current state of charge (SOC) of the battery in percentage."
|
||||||
)
|
)
|
||||||
|
charge_rates: Optional[list[float]] = Field(
|
||||||
|
default=None,
|
||||||
|
description="Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available.",
|
||||||
|
examples=[[0.0, 0.25, 0.5, 0.75, 1.0], None],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class HomeApplianceParameters(DeviceParameters):
|
class HomeApplianceParameters(DeviceParameters):
|
||||||
|
|||||||
@@ -462,6 +462,7 @@ class GeneticOptimizationParameters(
|
|||||||
capacity_wh=electric_vehicle_config.capacity_wh,
|
capacity_wh=electric_vehicle_config.capacity_wh,
|
||||||
charging_efficiency=electric_vehicle_config.charging_efficiency,
|
charging_efficiency=electric_vehicle_config.charging_efficiency,
|
||||||
discharging_efficiency=electric_vehicle_config.discharging_efficiency,
|
discharging_efficiency=electric_vehicle_config.discharging_efficiency,
|
||||||
|
charge_rates=electric_vehicle_config.charge_rates,
|
||||||
max_charge_power_w=electric_vehicle_config.max_charge_power_w,
|
max_charge_power_w=electric_vehicle_config.max_charge_power_w,
|
||||||
min_soc_percentage=electric_vehicle_config.min_soc_percentage,
|
min_soc_percentage=electric_vehicle_config.min_soc_percentage,
|
||||||
max_soc_percentage=electric_vehicle_config.max_soc_percentage,
|
max_soc_percentage=electric_vehicle_config.max_soc_percentage,
|
||||||
|
|||||||
Reference in New Issue
Block a user