fix: pydantic extra keywords deprecated (#753)

Pydantic deprecates using extra keyword arguments on Field.
Used json_schema_extra instead.

Deprecated in Pydantic V2.0 to be removed in V3.0.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2025-11-10 16:57:44 +01:00
committed by GitHub
parent 54b0622a96
commit e7b43782a4
44 changed files with 1956 additions and 1194 deletions

View File

@@ -21,7 +21,8 @@ class ElecPriceCommonProviderSettings(SettingsBaseModel):
"""Electricity Price Prediction Provider Configuration."""
ElecPriceImport: Optional[ElecPriceImportCommonSettings] = Field(
default=None, description="ElecPriceImport settings", examples=[None]
default=None,
json_schema_extra={"description": "ElecPriceImport settings", "examples": [None]},
)
@@ -30,31 +31,39 @@ class ElecPriceCommonSettings(SettingsBaseModel):
provider: Optional[str] = Field(
default=None,
description="Electricity price provider id of provider to be used.",
examples=["ElecPriceAkkudoktor"],
json_schema_extra={
"description": "Electricity price provider id of provider to be used.",
"examples": ["ElecPriceAkkudoktor"],
},
)
charges_kwh: Optional[float] = Field(
default=None,
ge=0,
description="Electricity price charges [€/kWh]. Will be added to variable market price.",
examples=[0.21],
json_schema_extra={
"description": "Electricity price charges [€/kWh]. Will be added to variable market price.",
"examples": [0.21],
},
)
vat_rate: Optional[float] = Field(
default=1.19,
ge=0,
description="VAT rate factor applied to electricity price when charges are used.",
examples=[1.19],
json_schema_extra={
"description": "VAT rate factor applied to electricity price when charges are used.",
"examples": [1.19],
},
)
provider_settings: ElecPriceCommonProviderSettings = Field(
default_factory=ElecPriceCommonProviderSettings,
description="Provider settings",
examples=[
# Example 1: Empty/default settings (all providers None)
{
"ElecPriceImport": None,
},
],
json_schema_extra={
"description": "Provider settings",
"examples": [
# Example 1: Empty/default settings (all providers None)
{
"ElecPriceImport": None,
},
],
},
)
# Validators

View File

@@ -21,7 +21,7 @@ class ElecPriceDataRecord(PredictionRecord):
"""
elecprice_marketprice_wh: Optional[float] = Field(
None, description="Electricity market price per Wh (€/Wh)"
None, json_schema_extra={"description": "Electricity market price per Wh (€/Wh)"}
)
# Computed fields
@@ -59,7 +59,8 @@ class ElecPriceProvider(PredictionProvider):
# overload
records: List[ElecPriceDataRecord] = Field(
default_factory=list, description="List of ElecPriceDataRecord records"
default_factory=list,
json_schema_extra={"description": "List of ElecPriceDataRecord records"},
)
@classmethod

View File

@@ -22,14 +22,18 @@ class ElecPriceImportCommonSettings(SettingsBaseModel):
import_file_path: Optional[Union[str, Path]] = Field(
default=None,
description="Path to the file to import elecprice data from.",
examples=[None, "/path/to/prices.json"],
json_schema_extra={
"description": "Path to the file to import elecprice data from.",
"examples": [None, "/path/to/prices.json"],
},
)
import_json: Optional[str] = Field(
default=None,
description="JSON string, dictionary of electricity price forecast value lists.",
examples=['{"elecprice_marketprice_wh": [0.0003384, 0.0003318, 0.0003284]}'],
json_schema_extra={
"description": "JSON string, dictionary of electricity price forecast value lists.",
"examples": ['{"elecprice_marketprice_wh": [0.0003384, 0.0003318, 0.0003284]}'],
},
)
# Validators

View File

@@ -22,10 +22,12 @@ class FeedInTariffCommonProviderSettings(SettingsBaseModel):
"""Feed In Tariff Prediction Provider Configuration."""
FeedInTariffFixed: Optional[FeedInTariffFixedCommonSettings] = Field(
default=None, description="FeedInTariffFixed settings", examples=[None]
default=None,
json_schema_extra={"description": "FeedInTariffFixed settings", "examples": [None]},
)
FeedInTariffImport: Optional[FeedInTariffImportCommonSettings] = Field(
default=None, description="FeedInTariffImport settings", examples=[None]
default=None,
json_schema_extra={"description": "FeedInTariffImport settings", "examples": [None]},
)
@@ -34,20 +36,24 @@ class FeedInTariffCommonSettings(SettingsBaseModel):
provider: Optional[str] = Field(
default=None,
description="Feed in tariff provider id of provider to be used.",
examples=["FeedInTariffFixed", "FeedInTarifImport"],
json_schema_extra={
"description": "Feed in tariff provider id of provider to be used.",
"examples": ["FeedInTariffFixed", "FeedInTarifImport"],
},
)
provider_settings: FeedInTariffCommonProviderSettings = Field(
default_factory=FeedInTariffCommonProviderSettings,
description="Provider settings",
examples=[
# Example 1: Empty/default settings (all providers None)
{
"FeedInTariffFixed": None,
"FeedInTariffImport": None,
},
],
json_schema_extra={
"description": "Provider settings",
"examples": [
# Example 1: Empty/default settings (all providers None)
{
"FeedInTariffFixed": None,
"FeedInTariffImport": None,
},
],
},
)
# Validators

View File

@@ -20,7 +20,9 @@ class FeedInTariffDataRecord(PredictionRecord):
"""
feed_in_tariff_wh: Optional[float] = Field(None, description="Feed in tariff per Wh (€/Wh)")
feed_in_tariff_wh: Optional[float] = Field(
None, json_schema_extra={"description": "Feed in tariff per Wh (€/Wh)"}
)
# Computed fields
@computed_field # type: ignore[prop-decorator]
@@ -46,7 +48,8 @@ class FeedInTariffProvider(PredictionProvider):
# overload
records: List[FeedInTariffDataRecord] = Field(
default_factory=list, description="List of FeedInTariffDataRecord records"
default_factory=list,
json_schema_extra={"description": "List of FeedInTariffDataRecord records"},
)
@classmethod

View File

@@ -16,8 +16,10 @@ class FeedInTariffFixedCommonSettings(SettingsBaseModel):
feed_in_tariff_kwh: Optional[float] = Field(
default=None,
ge=0,
description="Electricity price feed in tariff [€/kWH].",
examples=[0.078],
json_schema_extra={
"description": "Electricity price feed in tariff [€/kWH].",
"examples": [0.078],
},
)

View File

@@ -21,13 +21,17 @@ class FeedInTariffImportCommonSettings(SettingsBaseModel):
import_file_path: Optional[Union[str, Path]] = Field(
default=None,
description="Path to the file to import feed in tariff data from.",
examples=[None, "/path/to/feedintariff.json"],
json_schema_extra={
"description": "Path to the file to import feed in tariff data from.",
"examples": [None, "/path/to/feedintariff.json"],
},
)
import_json: Optional[str] = Field(
default=None,
description="JSON string, dictionary of feed in tariff forecast value lists.",
examples=['{"fead_in_tariff_wh": [0.000078, 0.000078, 0.000023]}'],
json_schema_extra={
"description": "JSON string, dictionary of feed in tariff forecast value lists.",
"examples": ['{"fead_in_tariff_wh": [0.000078, 0.000078, 0.000023]}'],
},
)
# Validators

View File

@@ -25,13 +25,14 @@ class LoadCommonProviderSettings(SettingsBaseModel):
"""Load Prediction Provider Configuration."""
LoadAkkudoktor: Optional[LoadAkkudoktorCommonSettings] = Field(
default=None, description="LoadAkkudoktor settings", examples=[None]
default=None,
json_schema_extra={"description": "LoadAkkudoktor settings", "examples": [None]},
)
LoadVrm: Optional[LoadVrmCommonSettings] = Field(
default=None, description="LoadVrm settings", examples=[None]
default=None, json_schema_extra={"description": "LoadVrm settings", "examples": [None]}
)
LoadImport: Optional[LoadImportCommonSettings] = Field(
default=None, description="LoadImport settings", examples=[None]
default=None, json_schema_extra={"description": "LoadImport settings", "examples": [None]}
)
@@ -40,21 +41,25 @@ class LoadCommonSettings(SettingsBaseModel):
provider: Optional[str] = Field(
default=None,
description="Load provider id of provider to be used.",
examples=["LoadAkkudoktor"],
json_schema_extra={
"description": "Load provider id of provider to be used.",
"examples": ["LoadAkkudoktor"],
},
)
provider_settings: LoadCommonProviderSettings = Field(
default_factory=LoadCommonProviderSettings,
description="Provider settings",
examples=[
# Example 1: Empty/default settings (all providers None)
{
"LoadAkkudoktor": None,
"LoadVrm": None,
"LoadImport": None,
},
],
json_schema_extra={
"description": "Provider settings",
"examples": [
# Example 1: Empty/default settings (all providers None)
{
"LoadAkkudoktor": None,
"LoadVrm": None,
"LoadImport": None,
},
],
},
)
# Validators

View File

@@ -16,7 +16,7 @@ class LoadDataRecord(PredictionRecord):
"""Represents a load data record containing various load attributes at a specific datetime."""
loadforecast_power_w: Optional[float] = Field(
default=None, description="Predicted load mean value (W)."
default=None, json_schema_extra={"description": "Predicted load mean value (W)."}
)
@@ -42,7 +42,7 @@ class LoadProvider(PredictionProvider):
# overload
records: List[LoadDataRecord] = Field(
default_factory=list, description="List of LoadDataRecord records"
default_factory=list, json_schema_extra={"description": "List of LoadDataRecord records"}
)
@classmethod

View File

@@ -15,7 +15,8 @@ class LoadAkkudoktorCommonSettings(SettingsBaseModel):
"""Common settings for load data import from file."""
loadakkudoktor_year_energy_kwh: Optional[float] = Field(
default=None, description="Yearly energy consumption (kWh).", examples=[40421]
default=None,
json_schema_extra={"description": "Yearly energy consumption (kWh).", "examples": [40421]},
)
@@ -23,11 +24,11 @@ class LoadAkkudoktorDataRecord(LoadDataRecord):
"""Represents a load data record with extra fields for LoadAkkudoktor."""
loadakkudoktor_mean_power_w: Optional[float] = Field(
default=None, description="Predicted load mean value (W)."
default=None, json_schema_extra={"description": "Predicted load mean value (W)."}
)
loadakkudoktor_std_power_w: Optional[float] = Field(
default=None, description="Predicted load standard deviation (W)."
default=None, json_schema_extra={"description": "Predicted load standard deviation (W)."}
)
@@ -35,7 +36,8 @@ class LoadAkkudoktor(LoadProvider):
"""Fetch Load forecast data from Akkudoktor load profiles."""
records: list[LoadAkkudoktorDataRecord] = Field(
default_factory=list, description="List of LoadAkkudoktorDataRecord records"
default_factory=list,
json_schema_extra={"description": "List of LoadAkkudoktorDataRecord records"},
)
@classmethod

View File

@@ -22,13 +22,17 @@ class LoadImportCommonSettings(SettingsBaseModel):
import_file_path: Optional[Union[str, Path]] = Field(
default=None,
description="Path to the file to import load data from.",
examples=[None, "/path/to/yearly_load.json"],
json_schema_extra={
"description": "Path to the file to import load data from.",
"examples": [None, "/path/to/yearly_load.json"],
},
)
import_json: Optional[str] = Field(
default=None,
description="JSON string, dictionary of load forecast value lists.",
examples=['{"load0_mean": [676.71, 876.19, 527.13]}'],
json_schema_extra={
"description": "JSON string, dictionary of load forecast value lists.",
"examples": ['{"load0_mean": [676.71, 876.19, 527.13]}'],
},
)
# Validators

View File

@@ -27,9 +27,15 @@ class LoadVrmCommonSettings(SettingsBaseModel):
"""Common settings for VRM API."""
load_vrm_token: str = Field(
default="your-token", description="Token for Connecting VRM API", examples=["your-token"]
default="your-token",
json_schema_extra={
"description": "Token for Connecting VRM API",
"examples": ["your-token"],
},
)
load_vrm_idsite: int = Field(
default=12345, json_schema_extra={"description": "VRM-Installation-ID", "examples": [12345]}
)
load_vrm_idsite: int = Field(default=12345, description="VRM-Installation-ID", examples=[12345])
class LoadVrm(LoadProvider):

View File

@@ -70,13 +70,17 @@ class PredictionCommonSettings(SettingsBaseModel):
"""
hours: Optional[int] = Field(
default=48, ge=0, description="Number of hours into the future for predictions"
default=48,
ge=0,
json_schema_extra={"description": "Number of hours into the future for predictions"},
)
historic_hours: Optional[int] = Field(
default=48,
ge=0,
description="Number of hours into the past for historical predictions data",
json_schema_extra={
"description": "Number of hours into the past for historical predictions data"
},
)
@@ -107,7 +111,9 @@ class Prediction(PredictionContainer):
WeatherClearOutside,
WeatherImport,
]
] = Field(default_factory=list, description="List of prediction providers")
] = Field(
default_factory=list, json_schema_extra={"description": "List of prediction providers"}
)
# Initialize forecast providers, all are singletons.

View File

@@ -72,8 +72,7 @@ class PredictionSequence(DataSequence):
Usage:
# Example of creating, adding, and using PredictionSequence
class DerivedSequence(PredictionSquence):
records: List[DerivedPredictionRecord] = Field(default_factory=list,
description="List of prediction records")
records: List[DerivedPredictionRecord] = Field(default_factory=list, json_schema_extra={ "description": "List of prediction records" })
seq = DerivedSequence()
seq.insert(DerivedPredictionRecord(date_time=datetime.now(), temperature=72))
@@ -89,7 +88,7 @@ class PredictionSequence(DataSequence):
# To be overloaded by derived classes.
records: List[PredictionRecord] = Field(
default_factory=list, description="List of prediction records"
default_factory=list, json_schema_extra={"description": "List of prediction records"}
)
@@ -249,5 +248,5 @@ class PredictionContainer(PredictionStartEndKeepMixin, DataContainer):
# To be overloaded by derived classes.
providers: List[PredictionProvider] = Field(
default_factory=list, description="List of prediction providers"
default_factory=list, json_schema_extra={"description": "List of prediction providers"}
)

View File

@@ -23,77 +23,118 @@ pvforecast_providers = [
class PVForecastPlaneSetting(SettingsBaseModel):
"""PV Forecast Plane Configuration."""
# latitude: Optional[float] = Field(default=None, description="Latitude in decimal degrees, between -90 and 90, north is positive (ISO 19115) (°)")
# latitude: Optional[float] = Field(default=None, json_schema_extra={ "description": "Latitude in decimal degrees, between -90 and 90, north is positive (ISO 19115) (°)" })
surface_tilt: Optional[float] = Field(
default=30.0,
ge=0.0,
le=90.0,
description="Tilt angle from horizontal plane. Ignored for two-axis tracking.",
examples=[10.0, 20.0],
json_schema_extra={
"description": "Tilt angle from horizontal plane. Ignored for two-axis tracking.",
"examples": [10.0, 20.0],
},
)
surface_azimuth: Optional[float] = Field(
default=180.0,
ge=0.0,
le=360.0,
description="Orientation (azimuth angle) of the (fixed) plane. Clockwise from north (north=0, east=90, south=180, west=270).",
examples=[180.0, 90.0],
json_schema_extra={
"description": "Orientation (azimuth angle) of the (fixed) plane. Clockwise from north (north=0, east=90, south=180, west=270).",
"examples": [180.0, 90.0],
},
)
userhorizon: Optional[List[float]] = Field(
default=None,
description="Elevation of horizon in degrees, at equally spaced azimuth clockwise from north.",
examples=[[10.0, 20.0, 30.0], [5.0, 15.0, 25.0]],
json_schema_extra={
"description": "Elevation of horizon in degrees, at equally spaced azimuth clockwise from north.",
"examples": [[10.0, 20.0, 30.0], [5.0, 15.0, 25.0]],
},
)
peakpower: Optional[float] = Field(
default=None, description="Nominal power of PV system in kW.", examples=[5.0, 3.5]
default=None,
json_schema_extra={
"description": "Nominal power of PV system in kW.",
"examples": [5.0, 3.5],
},
)
pvtechchoice: Optional[str] = Field(
default="crystSi", description="PV technology. One of 'crystSi', 'CIS', 'CdTe', 'Unknown'."
default="crystSi",
json_schema_extra={
"description": "PV technology. One of 'crystSi', 'CIS', 'CdTe', 'Unknown'."
},
)
mountingplace: Optional[str] = Field(
default="free",
description="Type of mounting for PV system. Options are 'free' for free-standing and 'building' for building-integrated.",
json_schema_extra={
"description": "Type of mounting for PV system. Options are 'free' for free-standing and 'building' for building-integrated."
},
)
loss: Optional[float] = Field(
default=14.0, json_schema_extra={"description": "Sum of PV system losses in percent"}
)
loss: Optional[float] = Field(default=14.0, description="Sum of PV system losses in percent")
trackingtype: Optional[int] = Field(
default=None,
ge=0,
le=5,
description="Type of suntracking. 0=fixed, 1=single horizontal axis aligned north-south, 2=two-axis tracking, 3=vertical axis tracking, 4=single horizontal axis aligned east-west, 5=single inclined axis aligned north-south.",
examples=[0, 1, 2, 3, 4, 5],
json_schema_extra={
"description": "Type of suntracking. 0=fixed, 1=single horizontal axis aligned north-south, 2=two-axis tracking, 3=vertical axis tracking, 4=single horizontal axis aligned east-west, 5=single inclined axis aligned north-south.",
"examples": [0, 1, 2, 3, 4, 5],
},
)
optimal_surface_tilt: Optional[bool] = Field(
default=False,
description="Calculate the optimum tilt angle. Ignored for two-axis tracking.",
examples=[False],
json_schema_extra={
"description": "Calculate the optimum tilt angle. Ignored for two-axis tracking.",
"examples": [False],
},
)
optimalangles: Optional[bool] = Field(
default=False,
description="Calculate the optimum tilt and azimuth angles. Ignored for two-axis tracking.",
examples=[False],
json_schema_extra={
"description": "Calculate the optimum tilt and azimuth angles. Ignored for two-axis tracking.",
"examples": [False],
},
)
albedo: Optional[float] = Field(
default=None,
description="Proportion of the light hitting the ground that it reflects back.",
examples=[None],
json_schema_extra={
"description": "Proportion of the light hitting the ground that it reflects back.",
"examples": [None],
},
)
module_model: Optional[str] = Field(
default=None, description="Model of the PV modules of this plane.", examples=[None]
default=None,
json_schema_extra={
"description": "Model of the PV modules of this plane.",
"examples": [None],
},
)
inverter_model: Optional[str] = Field(
default=None, description="Model of the inverter of this plane.", examples=[None]
default=None,
json_schema_extra={
"description": "Model of the inverter of this plane.",
"examples": [None],
},
)
inverter_paco: Optional[int] = Field(
default=None, description="AC power rating of the inverter [W].", examples=[6000, 4000]
default=None,
json_schema_extra={
"description": "AC power rating of the inverter [W].",
"examples": [6000, 4000],
},
)
modules_per_string: Optional[int] = Field(
default=None,
description="Number of the PV modules of the strings of this plane.",
examples=[20],
json_schema_extra={
"description": "Number of the PV modules of the strings of this plane.",
"examples": [20],
},
)
strings_per_inverter: Optional[int] = Field(
default=None,
description="Number of the strings of the inverter of this plane.",
examples=[2],
json_schema_extra={
"description": "Number of the strings of the inverter of this plane.",
"examples": [2],
},
)
@model_validator(mode="after")
@@ -124,10 +165,12 @@ class PVForecastCommonProviderSettings(SettingsBaseModel):
"""PV Forecast Provider Configuration."""
PVForecastImport: Optional[PVForecastImportCommonSettings] = Field(
default=None, description="PVForecastImport settings", examples=[None]
default=None,
json_schema_extra={"description": "PVForecastImport settings", "examples": [None]},
)
PVForecastVrm: Optional[PVForecastVrmCommonSettings] = Field(
default=None, description="PVForecastVrm settings", examples=[None]
default=None,
json_schema_extra={"description": "PVForecastVrm settings", "examples": [None]},
)
@@ -141,72 +184,80 @@ class PVForecastCommonSettings(SettingsBaseModel):
provider: Optional[str] = Field(
default=None,
description="PVForecast provider id of provider to be used.",
examples=["PVForecastAkkudoktor"],
json_schema_extra={
"description": "PVForecast provider id of provider to be used.",
"examples": ["PVForecastAkkudoktor"],
},
)
provider_settings: PVForecastCommonProviderSettings = Field(
default_factory=PVForecastCommonProviderSettings,
description="Provider settings",
examples=[
# Example 1: Empty/default settings (all providers None)
{
"PVForecastImport": None,
"PVForecastVrm": None,
},
],
json_schema_extra={
"description": "Provider settings",
"examples": [
# Example 1: Empty/default settings (all providers None)
{
"PVForecastImport": None,
"PVForecastVrm": None,
},
],
},
)
planes: Optional[list[PVForecastPlaneSetting]] = Field(
default=None,
description="Plane configuration.",
examples=[
[
{
"surface_tilt": 10.0,
"surface_azimuth": 180.0,
"userhorizon": [10.0, 20.0, 30.0],
"peakpower": 5.0,
"pvtechchoice": "crystSi",
"mountingplace": "free",
"loss": 14.0,
"trackingtype": 0,
"optimal_surface_tilt": False,
"optimalangles": False,
"albedo": None,
"module_model": None,
"inverter_model": None,
"inverter_paco": 6000,
"modules_per_string": 20,
"strings_per_inverter": 2,
},
{
"surface_tilt": 20.0,
"surface_azimuth": 90.0,
"userhorizon": [5.0, 15.0, 25.0],
"peakpower": 3.5,
"pvtechchoice": "crystSi",
"mountingplace": "free",
"loss": 14.0,
"trackingtype": 1,
"optimal_surface_tilt": False,
"optimalangles": False,
"albedo": None,
"module_model": None,
"inverter_model": None,
"inverter_paco": 4000,
"modules_per_string": 20,
"strings_per_inverter": 2,
},
]
],
json_schema_extra={
"description": "Plane configuration.",
"examples": [
[
{
"surface_tilt": 10.0,
"surface_azimuth": 180.0,
"userhorizon": [10.0, 20.0, 30.0],
"peakpower": 5.0,
"pvtechchoice": "crystSi",
"mountingplace": "free",
"loss": 14.0,
"trackingtype": 0,
"optimal_surface_tilt": False,
"optimalangles": False,
"albedo": None,
"module_model": None,
"inverter_model": None,
"inverter_paco": 6000,
"modules_per_string": 20,
"strings_per_inverter": 2,
},
{
"surface_tilt": 20.0,
"surface_azimuth": 90.0,
"userhorizon": [5.0, 15.0, 25.0],
"peakpower": 3.5,
"pvtechchoice": "crystSi",
"mountingplace": "free",
"loss": 14.0,
"trackingtype": 1,
"optimal_surface_tilt": False,
"optimalangles": False,
"albedo": None,
"module_model": None,
"inverter_model": None,
"inverter_paco": 4000,
"modules_per_string": 20,
"strings_per_inverter": 2,
},
]
],
},
)
max_planes: Optional[int] = Field(
default=0,
ge=0,
description="Maximum number of planes that can be set",
examples=[1, 2],
json_schema_extra={
"description": "Maximum number of planes that can be set",
"examples": [1, 2],
},
)
# Validators

View File

@@ -16,8 +16,12 @@ from akkudoktoreos.prediction.predictionabc import PredictionProvider, Predictio
class PVForecastDataRecord(PredictionRecord):
"""Represents a pvforecast data record containing various pvforecast attributes at a specific datetime."""
pvforecast_dc_power: Optional[float] = Field(default=None, description="Total DC power (W).")
pvforecast_ac_power: Optional[float] = Field(default=None, description="Total AC power (W).")
pvforecast_dc_power: Optional[float] = Field(
default=None, json_schema_extra={"description": "Total DC power (W)."}
)
pvforecast_ac_power: Optional[float] = Field(
default=None, json_schema_extra={"description": "Total AC power (W)."}
)
class PVForecastProvider(PredictionProvider):
@@ -42,7 +46,8 @@ class PVForecastProvider(PredictionProvider):
# overload
records: List[PVForecastDataRecord] = Field(
default_factory=list, description="List of PVForecastDataRecord records"
default_factory=list,
json_schema_extra={"description": "List of PVForecastDataRecord records"},
)
@classmethod

View File

@@ -157,13 +157,13 @@ class PVForecastAkkudoktorDataRecord(PVForecastDataRecord):
"""Represents a Akkudoktor specific pvforecast data record containing various pvforecast attributes at a specific datetime."""
pvforecastakkudoktor_ac_power_measured: Optional[float] = Field(
default=None, description="Total AC power measured (W)"
default=None, json_schema_extra={"description": "Total AC power measured (W)"}
)
pvforecastakkudoktor_wind_speed_10m: Optional[float] = Field(
default=None, description="Wind Speed 10m (kmph)"
default=None, json_schema_extra={"description": "Wind Speed 10m (kmph)"}
)
pvforecastakkudoktor_temp_air: Optional[float] = Field(
default=None, description="Temperature (°C)"
default=None, json_schema_extra={"description": "Temperature (°C)"}
)
# Computed fields
@@ -209,7 +209,8 @@ class PVForecastAkkudoktor(PVForecastProvider):
# overload
records: List[PVForecastAkkudoktorDataRecord] = Field(
default_factory=list, description="List of PVForecastAkkudoktorDataRecord records"
default_factory=list,
json_schema_extra={"description": "List of PVForecastAkkudoktorDataRecord records"},
)
@classmethod

View File

@@ -22,14 +22,18 @@ class PVForecastImportCommonSettings(SettingsBaseModel):
import_file_path: Optional[Union[str, Path]] = Field(
default=None,
description="Path to the file to import PV forecast data from.",
examples=[None, "/path/to/pvforecast.json"],
json_schema_extra={
"description": "Path to the file to import PV forecast data from.",
"examples": [None, "/path/to/pvforecast.json"],
},
)
import_json: Optional[str] = Field(
default=None,
description="JSON string, dictionary of PV forecast value lists.",
examples=['{"pvforecast_ac_power": [0, 8.05, 352.91]}'],
json_schema_extra={
"description": "JSON string, dictionary of PV forecast value lists.",
"examples": ['{"pvforecast_ac_power": [0, 8.05, 352.91]}'],
},
)
# Validators

View File

@@ -27,10 +27,14 @@ class PVForecastVrmCommonSettings(SettingsBaseModel):
"""Common settings for VRM API."""
pvforecast_vrm_token: str = Field(
default="your-token", description="Token for Connecting VRM API", examples=["your-token"]
default="your-token",
json_schema_extra={
"description": "Token for Connecting VRM API",
"examples": ["your-token"],
},
)
pvforecast_vrm_idsite: int = Field(
default=12345, description="VRM-Installation-ID", examples=[12345]
default=12345, json_schema_extra={"description": "VRM-Installation-ID", "examples": [12345]}
)

View File

@@ -23,7 +23,8 @@ class WeatherCommonProviderSettings(SettingsBaseModel):
"""Weather Forecast Provider Configuration."""
WeatherImport: Optional[WeatherImportCommonSettings] = Field(
default=None, description="WeatherImport settings", examples=[None]
default=None,
json_schema_extra={"description": "WeatherImport settings", "examples": [None]},
)
@@ -32,19 +33,23 @@ class WeatherCommonSettings(SettingsBaseModel):
provider: Optional[str] = Field(
default=None,
description="Weather provider id of provider to be used.",
examples=["WeatherImport"],
json_schema_extra={
"description": "Weather provider id of provider to be used.",
"examples": ["WeatherImport"],
},
)
provider_settings: WeatherCommonProviderSettings = Field(
default_factory=WeatherCommonProviderSettings,
description="Provider settings",
examples=[
# Example 1: Empty/default settings (all providers None)
{
"WeatherImport": None,
},
],
json_schema_extra={
"description": "Provider settings",
"examples": [
# Example 1: Empty/default settings (all providers None)
{
"WeatherImport": None,
},
],
},
)
# Validators

View File

@@ -47,48 +47,68 @@ class WeatherDataRecord(PredictionRecord):
"""
weather_total_clouds: Optional[float] = Field(
default=None, description="Total Clouds (% Sky Obscured)"
default=None, json_schema_extra={"description": "Total Clouds (% Sky Obscured)"}
)
weather_low_clouds: Optional[float] = Field(
default=None, description="Low Clouds (% Sky Obscured)"
default=None, json_schema_extra={"description": "Low Clouds (% Sky Obscured)"}
)
weather_medium_clouds: Optional[float] = Field(
default=None, description="Medium Clouds (% Sky Obscured)"
default=None, json_schema_extra={"description": "Medium Clouds (% Sky Obscured)"}
)
weather_high_clouds: Optional[float] = Field(
default=None, description="High Clouds (% Sky Obscured)"
default=None, json_schema_extra={"description": "High Clouds (% Sky Obscured)"}
)
weather_visibility: Optional[float] = Field(
default=None, json_schema_extra={"description": "Visibility (m)"}
)
weather_fog: Optional[float] = Field(default=None, json_schema_extra={"description": "Fog (%)"})
weather_precip_type: Optional[str] = Field(
default=None, json_schema_extra={"description": "Precipitation Type"}
)
weather_visibility: Optional[float] = Field(default=None, description="Visibility (m)")
weather_fog: Optional[float] = Field(default=None, description="Fog (%)")
weather_precip_type: Optional[str] = Field(default=None, description="Precipitation Type")
weather_precip_prob: Optional[float] = Field(
default=None, description="Precipitation Probability (%)"
default=None, json_schema_extra={"description": "Precipitation Probability (%)"}
)
weather_precip_amt: Optional[float] = Field(
default=None, description="Precipitation Amount (mm)"
default=None, json_schema_extra={"description": "Precipitation Amount (mm)"}
)
weather_preciptable_water: Optional[float] = Field(
default=None, description="Precipitable Water (cm)"
default=None, json_schema_extra={"description": "Precipitable Water (cm)"}
)
weather_wind_speed: Optional[float] = Field(
default=None, json_schema_extra={"description": "Wind Speed (kmph)"}
)
weather_wind_direction: Optional[float] = Field(
default=None, json_schema_extra={"description": "Wind Direction (°)"}
)
weather_frost_chance: Optional[str] = Field(
default=None, json_schema_extra={"description": "Chance of Frost"}
)
weather_temp_air: Optional[float] = Field(
default=None, json_schema_extra={"description": "Temperature (°C)"}
)
weather_feels_like: Optional[float] = Field(
default=None, json_schema_extra={"description": "Feels Like (°C)"}
)
weather_dew_point: Optional[float] = Field(
default=None, json_schema_extra={"description": "Dew Point (°C)"}
)
weather_wind_speed: Optional[float] = Field(default=None, description="Wind Speed (kmph)")
weather_wind_direction: Optional[float] = Field(default=None, description="Wind Direction (°)")
weather_frost_chance: Optional[str] = Field(default=None, description="Chance of Frost")
weather_temp_air: Optional[float] = Field(default=None, description="Temperature (°C)")
weather_feels_like: Optional[float] = Field(default=None, description="Feels Like (°C)")
weather_dew_point: Optional[float] = Field(default=None, description="Dew Point (°C)")
weather_relative_humidity: Optional[float] = Field(
default=None, description="Relative Humidity (%)"
default=None, json_schema_extra={"description": "Relative Humidity (%)"}
)
weather_pressure: Optional[float] = Field(
default=None, json_schema_extra={"description": "Pressure (mb)"}
)
weather_ozone: Optional[float] = Field(
default=None, json_schema_extra={"description": "Ozone (du)"}
)
weather_pressure: Optional[float] = Field(default=None, description="Pressure (mb)")
weather_ozone: Optional[float] = Field(default=None, description="Ozone (du)")
weather_ghi: Optional[float] = Field(
default=None, description="Global Horizontal Irradiance (W/m2)"
default=None, json_schema_extra={"description": "Global Horizontal Irradiance (W/m2)"}
)
weather_dni: Optional[float] = Field(
default=None, description="Direct Normal Irradiance (W/m2)"
default=None, json_schema_extra={"description": "Direct Normal Irradiance (W/m2)"}
)
weather_dhi: Optional[float] = Field(
default=None, description="Diffuse Horizontal Irradiance (W/m2)"
default=None, json_schema_extra={"description": "Diffuse Horizontal Irradiance (W/m2)"}
)
@@ -114,7 +134,7 @@ class WeatherProvider(PredictionProvider):
# overload
records: List[WeatherDataRecord] = Field(
default_factory=list, description="List of WeatherDataRecord records"
default_factory=list, json_schema_extra={"description": "List of WeatherDataRecord records"}
)
@classmethod

View File

@@ -22,14 +22,18 @@ class WeatherImportCommonSettings(SettingsBaseModel):
import_file_path: Optional[Union[str, Path]] = Field(
default=None,
description="Path to the file to import weather data from.",
examples=[None, "/path/to/weather_data.json"],
json_schema_extra={
"description": "Path to the file to import weather data from.",
"examples": [None, "/path/to/weather_data.json"],
},
)
import_json: Optional[str] = Field(
default=None,
description="JSON string, dictionary of weather forecast value lists.",
examples=['{"weather_temp_air": [18.3, 17.8, 16.9]}'],
json_schema_extra={
"description": "JSON string, dictionary of weather forecast value lists.",
"examples": ['{"weather_temp_air": [18.3, 17.8, 16.9]}'],
},
)
# Validators