pvforecast: Some values optional. Closes #292 (#293)

* temperature, relativehumidity_2m, windspeed_10m can be null
 * prettify pv_forecast_input_1.json (and add null value)
This commit is contained in:
Dominique Lasserre 2024-12-29 16:43:37 +01:00
parent b386c4be70
commit 267a9bf427
7 changed files with 11687 additions and 13 deletions

View File

@ -3331,8 +3331,15 @@
"properties": {
"temperature": {
"items": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
"type": "array",
"title": "Temperature"
},
@ -3462,8 +3469,15 @@
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
"type": "array"
},
{

View File

@ -32,7 +32,7 @@ class OptimizationParameters(BaseModel):
inverter: InverterParameters = InverterParameters()
eauto: Optional[ElectricVehicleParameters]
dishwasher: Optional[HomeApplianceParameters] = None
temperature_forecast: Optional[list[float]] = Field(
temperature_forecast: Optional[list[Optional[float]]] = Field(
default=None,
description="An array of floats representing the temperature forecast in degrees Celsius for different time intervals.",
)

View File

@ -109,9 +109,9 @@ class AkkudoktorForecastValue(PydanticBaseModel):
power: float
sunTilt: float
sunAzimuth: float
temperature: float
relativehumidity_2m: float
windspeed_10m: float
temperature: Optional[float]
relativehumidity_2m: Optional[float]
windspeed_10m: Optional[float]
class AkkudoktorForecast(PydanticBaseModel):

View File

@ -407,7 +407,7 @@ def fastapi_gesamtlast_simple(year_energy: float) -> list[float]:
class ForecastResponse(PydanticBaseModel):
temperature: list[float]
temperature: list[Optional[float]]
pvpower: list[float]

View File

@ -88,7 +88,7 @@ class VisualizationReport(ConfigMixin):
def create_line_chart(
self,
start_hour: Optional[int],
y_list: list[Union[np.ndarray, list[float]]],
y_list: list[Union[np.ndarray, list[Optional[float]], list[float]]],
title: str,
xlabel: str,
ylabel: str,

View File

@ -293,10 +293,9 @@ def test_timezone_behaviour(
forecast_temps = provider.key_to_series(
"pvforecastakkudoktor_temp_air", other_start_datetime, other_end_datetime
)
assert len(forecast_temps) == 24
assert forecast_temps.iloc[0] == 7.0
assert forecast_temps.iloc[1] == 6.5
assert forecast_temps.iloc[2] == 6.0
assert len(forecast_temps) == 23 # 24-1, first temperature is null
assert forecast_temps.iloc[0] == 6.5
assert forecast_temps.iloc[1] == 6.0
# Test fetching AC power forecast
other_end_datetime = other_start_datetime + to_duration("48 hours")

File diff suppressed because one or more lines are too long