Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Energyforecast.de as a data source #180

Merged
merged 13 commits into from
Dec 10, 2024
Prev Previous commit
Next Next commit
fixed problem
  • Loading branch information
moritzmair committed Nov 28, 2024
commit 4b193a03811cba9817d27ec2c66f01338a1c56fc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ def toEpochMilliSec(dt: datetime) -> int:
class Energyforecast:
URL = "https://www.energyforecast.de/api/v1/predictions/next_96_hours"

def __init__(self, token: str, session: aiohttp.ClientSession):
MARKET_AREAS = ("de")

def __init__(self, market_area, token: str, session: aiohttp.ClientSession):
self._token = token
self._session = session
self._market_area = market_area
self._marketdata = []

@property
Expand Down
4 changes: 3 additions & 1 deletion custom_components/epex_spot/SourceShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def __init__(self, config_entry: ConfigEntry, session: aiohttp.ClientSession):
)
elif config_entry.data[CONF_SOURCE] == CONF_SOURCE_ENERGYFORECAST:
self._source = Energyforecast.Energyforecast(
token=self._config_entry.data[CONF_TOKEN], session=session
market_area=config_entry.data[CONF_MARKET_AREA],
token=self._config_entry.data[CONF_TOKEN],
session=session
)

@property
Expand Down
5 changes: 4 additions & 1 deletion custom_components/epex_spot/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ async def async_step_source(self, user_input=None):
# Energyforecast API requires a token
elif self._source_name == CONF_SOURCE_ENERGYFORECAST:
data_schema = vol.Schema(
{vol.Required(CONF_TOKEN): vol.Coerce(str)}
{
vol.Required(CONF_MARKET_AREA): vol.In(sorted(areas)),
vol.Required(CONF_TOKEN): vol.Coerce(str)
}
)
else:
if self._source_name == CONF_SOURCE_AWATTAR:
Expand Down