Skip to content

Commit

Permalink
update async_setup_entry to retrieve optionsflow entry
Browse files Browse the repository at this point in the history
  • Loading branch information
pantherale0 committed Jan 6, 2024
1 parent f064d1f commit bb94e24
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/fuel_prices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ def _build_configured_areas(hass_areas: dict) -> list[dict]:

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Create ConfigEntry."""
hass.data.setdefault(DOMAIN, {})
_LOGGER.debug("Got request to setup entry.")
sources = entry.options.get(CONF_SOURCES, entry.data.get(CONF_SOURCES, None))
areas = entry.options.get(CONF_AREAS, entry.data.get(CONF_AREAS, None))
try:
fuel_prices: FuelPrices = FuelPrices.create(
enabled_sources=entry.data.get(CONF_SOURCES, None),
configured_areas=_build_configured_areas(entry.data[CONF_AREAS]),
enabled_sources=sources,
configured_areas=_build_configured_areas(areas),
)
await fuel_prices.update()
hass.data[DOMAIN][entry.entry_id] = FuelPricesCoordinator(
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = FuelPricesCoordinator(
hass, fuel_prices, entry.entry_id
)
except Exception as err:
Expand Down

0 comments on commit bb94e24

Please sign in to comment.