Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class UpdateConfig:

DATASTORE_VERSION = 103
DATASTORE_VERSION = 104

valid_topic = [
"^openWB/bat/config/bat_control_permitted$",
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down