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
4 changes: 2 additions & 2 deletions custom_components/epex_spot/EPEXSpot/smartENERGY/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ async def fetch(self):
data = await self._fetch_data(self.URL)
duration = data["interval"]
assert data["unit"].lower() == CT_PER_KWH.lower()
marketdata = self._extract_marketdata(data["data"], duration)
self._marketdata = self._extract_marketdata(data["data"], duration)

# compress data if required
if duration < self._duration:
self._marketdata = compress_marketdata(marketdata, self._duration)
self._marketdata = compress_marketdata(self.marketdata, self._duration)

async def _fetch_data(self, url):
async with self._session.get(url) as resp:
Expand Down
25 changes: 10 additions & 15 deletions custom_components/epex_spot/SourceShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,18 @@ def update_time(self):
def to_net_price(self, price_per_kwh):
net_p = price_per_kwh

# Retrieve tax and surcharge values from config
surcharge_abs = self._config_entry.options.get(
CONF_SURCHARGE_ABS, DEFAULT_SURCHARGE_ABS
)
tax = self._config_entry.options.get(CONF_TAX, DEFAULT_TAX)
# Standard calculation for other cases
if "Tibber API" not in self.name:
# Retrieve tax and surcharge values from config
surcharge_abs = self._config_entry.options.get(
CONF_SURCHARGE_ABS, DEFAULT_SURCHARGE_ABS
)
tax = self._config_entry.options.get(CONF_TAX, DEFAULT_TAX)

surcharge_pct = self._config_entry.options.get(
CONF_SURCHARGE_PERC, DEFAULT_SURCHARGE_PERC
)
surcharge_pct = self._config_entry.options.get(
CONF_SURCHARGE_PERC, DEFAULT_SURCHARGE_PERC
)

# Custom calculation for SMARTENERGY
if self.name == "smartENERGY API V1":
net_p *= 1.0 + (tax / 100.0)
net_p += surcharge_abs
net_p *= 1.0 + (surcharge_pct / 100.0)
# Standard calculation for other cases
elif "Tibber API" not in self.name:
net_p = net_p + abs(net_p) * surcharge_pct / 100
net_p += surcharge_abs
net_p *= 1 + (tax / 100.0)
Expand Down
15 changes: 10 additions & 5 deletions custom_components/epex_spot/test_smartenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@

async def main():
async with aiohttp.ClientSession() as session:
service = smartENERGY.smartENERGY(market_area="at", session=session)
durations = [15, 60]

await service.fetch()
print(f"count = {len(service.marketdata)}")
for e in service.marketdata:
print(f"{e.start_time}: {e.price_per_kwh} {UOM_EUR_PER_KWH}")
for duration in durations:
service = smartENERGY.smartENERGY(
market_area="at", duration=duration, session=session
)

await service.fetch()
print(f"{duration} count = {len(service.marketdata)}")
for e in service.marketdata:
print(f"{e.start_time}: {e.price_per_kwh} {UOM_EUR_PER_KWH}")


asyncio.run(main())