mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-10-11 11:56:17 +00:00
* add configurable VAT rate for electricity price calculations * add VAT rate configuration for electricity price calculations in docs * added vat_rate * fix: Format VAT rate field definition according to ruff formatting standards --------- Co-authored-by: Börni <kontakt@bernhardhientz.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from typing import Optional
|
|
|
|
from pydantic import Field, field_validator
|
|
|
|
from akkudoktoreos.config.configabc import SettingsBaseModel
|
|
from akkudoktoreos.prediction.elecpriceabc import ElecPriceProvider
|
|
from akkudoktoreos.prediction.elecpriceimport import ElecPriceImportCommonSettings
|
|
from akkudoktoreos.prediction.prediction import get_prediction
|
|
|
|
prediction_eos = get_prediction()
|
|
|
|
# Valid elecprice providers
|
|
elecprice_providers = [
|
|
provider.provider_id()
|
|
for provider in prediction_eos.providers
|
|
if isinstance(provider, ElecPriceProvider)
|
|
]
|
|
|
|
|
|
class ElecPriceCommonSettings(SettingsBaseModel):
|
|
"""Electricity Price Prediction Configuration."""
|
|
|
|
provider: Optional[str] = Field(
|
|
default=None,
|
|
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).", 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],
|
|
)
|
|
|
|
provider_settings: Optional[ElecPriceImportCommonSettings] = Field(
|
|
default=None, description="Provider settings", examples=[None]
|
|
)
|
|
|
|
# Validators
|
|
@field_validator("provider", mode="after")
|
|
@classmethod
|
|
def validate_provider(cls, value: Optional[str]) -> Optional[str]:
|
|
if value is None or value in elecprice_providers:
|
|
return value
|
|
raise ValueError(
|
|
f"Provider '{value}' is not a valid electricity price provider: {elecprice_providers}."
|
|
)
|