34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import annotations
|
|
from datetime import time, datetime
|
|
from EnergyPrice import EnergyPriceBase
|
|
from utils.time_helpers import in_range_local
|
|
from utils.calendar_pl import gov_energy_prices_shield
|
|
|
|
class TauronG12Provider(EnergyPriceBase):
|
|
low1 = (time(22,0), time(6,0))
|
|
low2 = (time(13,0), time(15,0))
|
|
high1 = (time(6,0), time(13,0))
|
|
high2 = (time(15,0), time(22,0))
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(**kwargs)
|
|
|
|
@staticmethod
|
|
def _rates(ts: datetime):
|
|
if gov_energy_prices_shield(ts):
|
|
tarcza_rates = 0.62 / 1.23
|
|
return {
|
|
"low": 0.57/1.23, "high": tarcza_rates
|
|
}
|
|
else:
|
|
raise RuntimeError("brak danych dla nie tarczy, trzeba ogarnąć")
|
|
|
|
def rate(self, ts):
|
|
rates = self._rates(ts)
|
|
t = self.to_local_dt(ts).time()
|
|
if in_range_local(t, self.low1) or in_range_local(t, self.low2):
|
|
return rates["low"]
|
|
if in_range_local(t, self.high1) or in_range_local(t, self.high2):
|
|
return rates["high"]
|
|
return rates["high"]
|