mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-10-11 11:56:17 +00:00
Fix2 electricity price prediction. (#296)
Normalize electricity price prediction to €/Wh. Provide electricity price prediction by €/kWh for convenience. Allow to configure electricity price charges by €/kWh. Also added error page to fastapi rest server to get rid of annoying unrelated fault messages during testing. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ Notes:
|
||||
from abc import abstractmethod
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import Field, computed_field
|
||||
|
||||
from akkudoktoreos.prediction.predictionabc import PredictionProvider, PredictionRecord
|
||||
from akkudoktoreos.utils.logutil import get_logger
|
||||
@@ -23,10 +23,22 @@ class ElecPriceDataRecord(PredictionRecord):
|
||||
|
||||
"""
|
||||
|
||||
elecprice_marketprice: Optional[float] = Field(
|
||||
None, description="Electricity market price (€/KWh)"
|
||||
elecprice_marketprice_wh: Optional[float] = Field(
|
||||
None, description="Electricity market price per Wh (€/Wh)"
|
||||
)
|
||||
|
||||
# Computed fields
|
||||
@computed_field # type: ignore[prop-decorator]
|
||||
@property
|
||||
def elecprice_marketprice_kwh(self) -> Optional[float]:
|
||||
"""Electricity market price per kWh (€/kWh).
|
||||
|
||||
Convenience attribute calculated from `elecprice_marketprice_wh`.
|
||||
"""
|
||||
if self.elecprice_marketprice_wh is None:
|
||||
return None
|
||||
return self.elecprice_marketprice_wh * 1000.0
|
||||
|
||||
|
||||
class ElecPriceProvider(PredictionProvider):
|
||||
"""Abstract base class for electricity price providers.
|
||||
|
Reference in New Issue
Block a user