Skip to content

Commit

Permalink
Merge pull request #189 from JaccoR/config-flow-updates
Browse files Browse the repository at this point in the history
Fixes config flow
  • Loading branch information
Roeland54 authored Oct 5, 2024
2 parents 264d52e + b6c2c77 commit f5a68f1
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions custom_components/entsoe/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

from .const import (
AREA_INFO,
ENERGY_SCALES,
CALCULATION_MODE,
COMPONENT_TITLE,
CONF_ADVANCED_OPTIONS,
CONF_API_KEY,
CONF_AREA,
Expand All @@ -36,6 +36,7 @@
DEFAULT_ENERGY_SCALE,
DEFAULT_MODIFYER,
DOMAIN,
ENERGY_SCALES,
UNIQUE_ID,
)

Expand Down Expand Up @@ -86,16 +87,17 @@ async def async_step_user(
errors["base"] = "already_configured"
already_configured = True

if self.advanced_options:
return await self.async_step_extra()
user_input[CONF_VAT_VALUE] = 0
user_input[CONF_MODIFYER] = DEFAULT_MODIFYER
user_input[CONF_CURRENCY] = DEFAULT_CURRENCY
user_input[CONF_ENERGY_SCALE] = DEFAULT_ENERGY_SCALE
user_input[CONF_CALCULATION_MODE] = CALCULATION_MODE["default"]
if not already_configured:
if self.advanced_options:
return await self.async_step_extra()
user_input[CONF_VAT_VALUE] = 0
user_input[CONF_MODIFYER] = DEFAULT_MODIFYER
user_input[CONF_CURRENCY] = DEFAULT_CURRENCY
user_input[CONF_ENERGY_SCALE] = DEFAULT_ENERGY_SCALE
user_input[CONF_CALCULATION_MODE] = CALCULATION_MODE["default"]

return self.async_create_entry(
title=self.name,
title=self.name or COMPONENT_TITLE,
data={},
options={
CONF_API_KEY: user_input[CONF_API_KEY],
Expand Down Expand Up @@ -134,8 +136,6 @@ async def async_step_user(

async def async_step_extra(self, user_input=None):
"""Handle VAT, template and calculation mode if requested."""
await self.async_set_unique_id(UNIQUE_ID)
self._abort_if_unique_id_configured()
errors = {}
already_configured = False

Expand Down Expand Up @@ -175,7 +175,7 @@ async def async_step_extra(self, user_input=None):
if template_ok:
if "current_price" in user_input[CONF_MODIFYER]:
return self.async_create_entry(
title=self.name,
title=self.name or COMPONENT_TITLE,
data={},
options={
CONF_API_KEY: user_input[CONF_API_KEY],
Expand Down Expand Up @@ -208,9 +208,9 @@ async def async_step_extra(self, user_input=None):
vol.Optional(CONF_CURRENCY, default=DEFAULT_CURRENCY): vol.All(
vol.Coerce(str)
),
vol.Optional(CONF_ENERGY_SCALE, default=DEFAULT_ENERGY_SCALE): vol.In(
list(ENERGY_SCALES.keys())
),
vol.Optional(
CONF_ENERGY_SCALE, default=DEFAULT_ENERGY_SCALE
): vol.In(list(ENERGY_SCALES.keys())),
vol.Optional(
CONF_CALCULATION_MODE, default=CALCULATION_MODE["default"]
): SelectSelector(
Expand Down

0 comments on commit f5a68f1

Please sign in to comment.