diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index c8c627a1c5..2b072475a5 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -57,7 +57,7 @@ class UpdateConfig: - DATASTORE_VERSION = 103 + DATASTORE_VERSION = 104 valid_topic = [ "^openWB/bat/config/bat_control_permitted$", @@ -2635,7 +2635,7 @@ def upgrade(topic: str, payload) -> None: if "openWB/optional/et/provider" == topic: return {"openWB/optional/ep/flexible_tariff/provider": decode_payload(payload)} self._loop_all_received_topics(upgrade) - self.__update_topic("openWB/system/datastore_version", 102) + self._append_datastore_version(102) def upgrade_datastore_103(self) -> None: def upgrade(topic: str, payload) -> None: @@ -2654,4 +2654,18 @@ def upgrade(topic: str, payload) -> None: }) return {component_topic: config_payload} self._loop_all_received_topics(upgrade) - self.__update_topic("openWB/system/datastore_version", 103) + self._append_datastore_version(103) + + def upgrade_datastore_104(self) -> None: + def upgrade(topic: str, payload) -> None: + if "openWB/optional/ep/flexible_tariff/provider" == topic: + provider = decode_payload(payload) + if provider["type"] == "awattar": + if provider["configuration"].get("net") is None: + provider["configuration"]["net"] = False + provider["configuration"]["fix"] = 0.015 + provider["configuration"]["proportional"] = 0.03 + provider["configuration"]["tax"] = 0.2 + return {topic: provider} + self._loop_all_received_topics(upgrade) + self._append_datastore_version(104) diff --git a/packages/modules/electricity_pricing/flexible_tariffs/awattar/config.py b/packages/modules/electricity_pricing/flexible_tariffs/awattar/config.py index 53becd62c8..6758b848a9 100644 --- a/packages/modules/electricity_pricing/flexible_tariffs/awattar/config.py +++ b/packages/modules/electricity_pricing/flexible_tariffs/awattar/config.py @@ -1,11 +1,20 @@ class AwattarTariffConfiguration: - def __init__(self, country: str = "de"): + def __init__(self, + country: str = "de", + net: bool = True, + fix: float = 0.015, + proportional: float = 3, + tax: float = 20) -> None: self.country = country + self.net = net + self.fix = fix + self.proportional = proportional + self.tax = tax class AwattarTariff: def __init__(self, - name: str = "aWATTar Hourly", + name: str = "aWATTar/tado° HOURLY", type: str = "awattar", official: bool = True, configuration: AwattarTariffConfiguration = None) -> None: diff --git a/packages/modules/electricity_pricing/flexible_tariffs/awattar/tariff.py b/packages/modules/electricity_pricing/flexible_tariffs/awattar/tariff.py index 7fa7e0155c..63d9aa9465 100644 --- a/packages/modules/electricity_pricing/flexible_tariffs/awattar/tariff.py +++ b/packages/modules/electricity_pricing/flexible_tariffs/awattar/tariff.py @@ -37,6 +37,9 @@ def fetch_prices(config: AwattarTariffConfiguration) -> Dict[int, float]: prices: Dict[int, float] = {} for data in raw_prices: formatted_price = data["marketprice"]/1000000 # €/MWh -> €/Wh + if config.net is False: + formatted_price = formatted_price + (formatted_price * config.proportional / 100) + config.fix + formatted_price = formatted_price * (1 + config.tax / 100) timestamp = data["start_timestamp"]/1000 # Epoch from ms in s prices.update({str(int(timestamp)): formatted_price}) return prices