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
2 changes: 1 addition & 1 deletion packages/control/optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def et_price_lower_than_limit(self, max_price: float):
return False

def et_get_current_price(self):
return self.data.et.get.prices[str(create_unix_timestamp_current_full_hour())]
return self.data.et.get.prices[str(int(create_unix_timestamp_current_full_hour()))]

def et_get_loading_hours(self, duration: float, remaining_time: float) -> List[int]:
"""
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/electricity_tariffs/awattar/tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def fetch_prices(config: AwattarTariffConfiguration) -> Dict[int, float]:
for data in raw_prices:
formatted_price = data["marketprice"]/1000000 # €/MWh -> €/Wh
timestamp = data["start_timestamp"]/1000 # Epoch from ms in s
prices.update({int(timestamp): formatted_price})
prices.update({str(int(timestamp)): formatted_price})
return prices


Expand Down
26 changes: 13 additions & 13 deletions packages/modules/electricity_tariffs/awattar/tariff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ def test_fetch_prices(requests_mock):
}

EXPECTED_PRICES = {
1698310800: 0.00014,
1698314400: 0.00013111,
1698318000: 0.00012009,
1698321600: 0.0001196,
1698325200: 0.00012001000000000001,
1698328800: 0.00013114,
1698332400: 0.00014291,
1698336000: 0.00015094999999999998,
1698339600: 0.00015099000000000002,
1698343200: 0.00013072,
1698346800: 0.00011906,
1698350400: 0.00011706000000000001,
1698354000: 0.00010485
"1698310800": 0.00014,
"1698314400": 0.00013111,
"1698318000": 0.00012009,
"1698321600": 0.0001196,
"1698325200": 0.00012001000000000001,
"1698328800": 0.00013114,
"1698332400": 0.00014291,
"1698336000": 0.00015094999999999998,
"1698339600": 0.00015099000000000002,
"1698343200": 0.00013072,
"1698346800": 0.00011906,
"1698350400": 0.00011706000000000001,
"1698354000": 0.00010485
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def fetch_prices(config: EnergyChartsTariffConfiguration) -> Dict[int, float]:
for price in raw_prices['price']:
price_arr.append((float(price + (config.surcharge*10))/1000000)) # €/MWh -> €/Wh + Aufschlag
prices: Dict[int, float] = {}
prices = dict(zip(raw_prices['unix_seconds'], price_arr))
prices = dict(zip([str(int(unix_seconds)) for unix_seconds in raw_prices['unix_seconds']], price_arr))
return prices


Expand Down
2 changes: 1 addition & 1 deletion packages/modules/electricity_tariffs/rabot/tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_raw_prices():
formatted_price = data["priceInCentPerKwh"]/100000 # Cent/kWh -> €/Wh
timestamp = datetime.datetime.fromisoformat(data["timestamp"]).astimezone(
pytz.timezone("Europe/Berlin")).timestamp()
prices.update({int(timestamp): formatted_price})
prices.update({str(int(timestamp)): formatted_price})
return prices


Expand Down
2 changes: 1 addition & 1 deletion packages/modules/electricity_tariffs/tibber/tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def fetch_prices(config: TibberTariffConfiguration) -> Dict[int, float]:
for price_data in sorted_market_prices:
start_time_epoch = datetime.fromisoformat(price_data['startsAt']).timestamp()
if current_hour <= start_time_epoch:
prices.update({start_time_epoch: price_data['total'] / 1000})
prices.update({str(int(start_time_epoch)): price_data['total'] / 1000})
else:
error = response_json['errors'][0]['message']
raise Exception(error)
Expand Down
34 changes: 17 additions & 17 deletions packages/modules/electricity_tariffs/tibber/tariff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ def test_fetch_prices(monkeypatch, requests_mock):
"tomorrow": []}}}}}}

EXPECTED_PRICES = {
1698382800: 0.0016862,
1698386400: 0.0023264,
1698390000: 0.0023024,
1698393600: 0.0017204,
1698397200: 0.0017213,
1698400800: 0.0018697,
1698404400: 0.0016899999999999999,
1698408000: 0.0015725000000000001,
1698411600: 0.0012997,
1698415200: 0.0014289,
1698418800: 0.0019176,
1698422400: 0.0021175,
1698426000: 0.0018902,
1698429600: 0.0012104,
1698433200: 0.0011332,
1698436800: 0.0008015,
1698440400: 0.0007698000000000001,
"1698382800": 0.0016862,
"1698386400": 0.0023264,
"1698390000": 0.0023024,
"1698393600": 0.0017204,
"1698397200": 0.0017213,
"1698400800": 0.0018697,
"1698404400": 0.0016899999999999999,
"1698408000": 0.0015725000000000001,
"1698411600": 0.0012997,
"1698415200": 0.0014289,
"1698418800": 0.0019176,
"1698422400": 0.0021175,
"1698426000": 0.0018902,
"1698429600": 0.0012104,
"1698433200": 0.0011332,
"1698436800": 0.0008015,
"1698440400": 0.0007698000000000001,
}
2 changes: 1 addition & 1 deletion packages/modules/electricity_tariffs/voltego/tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_raw_prices():
# timezone of the result should already be UTC as epoch does not support timezones
timestamp = datetime.datetime.fromisoformat(data["begin"]).astimezone(
pytz.timezone("Europe/Berlin")).timestamp()
prices.update({int(timestamp): formatted_price})
prices.update({str(int(timestamp)): formatted_price})
return prices


Expand Down