Skip to content

Commit

Permalink
Merge pull request #2752 from alandtse/dev
Browse files Browse the repository at this point in the history
fix: set option flow config_entry explicitly #2748
  • Loading branch information
alandtse authored Dec 16, 2024
2 parents 7d32d2f + 0a829cb commit bf28415
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config = OrderedDict()
self.config_entry = config_entry
self._config_entry = config_entry

async def async_step_init(
self, user_input: dict[str, Any] | None = None
Expand All @@ -883,7 +883,7 @@ async def async_step_init(
(
vol.Optional(
CONF_PUBLIC_URL,
default=self.config_entry.data.get(
default=self._config_entry.data.get(
CONF_PUBLIC_URL, DEFAULT_PUBLIC_URL
),
),
Expand All @@ -892,28 +892,28 @@ async def async_step_init(
(
vol.Optional(
CONF_INCLUDE_DEVICES,
default=self.config_entry.data.get(CONF_INCLUDE_DEVICES, ""),
default=self._config_entry.data.get(CONF_INCLUDE_DEVICES, ""),
),
str,
),
(
vol.Optional(
CONF_EXCLUDE_DEVICES,
default=self.config_entry.data.get(CONF_EXCLUDE_DEVICES, ""),
default=self._config_entry.data.get(CONF_EXCLUDE_DEVICES, ""),
),
str,
),
(
vol.Optional(
CONF_SCAN_INTERVAL,
default=self.config_entry.data.get(CONF_SCAN_INTERVAL, 120),
default=self._config_entry.data.get(CONF_SCAN_INTERVAL, 120),
),
int,
),
(
vol.Optional(
CONF_QUEUE_DELAY,
default=self.config_entry.data.get(
default=self._config_entry.data.get(
CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY
),
),
Expand All @@ -922,7 +922,7 @@ async def async_step_init(
(
vol.Optional(
CONF_EXTENDED_ENTITY_DISCOVERY,
default=self.config_entry.data.get(
default=self._config_entry.data.get(
CONF_EXTENDED_ENTITY_DISCOVERY,
DEFAULT_EXTENDED_ENTITY_DISCOVERY,
),
Expand All @@ -932,7 +932,7 @@ async def async_step_init(
(
vol.Optional(
CONF_DEBUG,
default=self.config_entry.data.get(CONF_DEBUG, DEFAULT_DEBUG),
default=self._config_entry.data.get(CONF_DEBUG, DEFAULT_DEBUG),
),
bool,
),
Expand All @@ -941,27 +941,27 @@ async def async_step_init(

if user_input is not None:
"""Preserve these parameters"""
if CONF_URL in self.config_entry.data:
user_input[CONF_URL] = self.config_entry.data[CONF_URL]
if CONF_EMAIL in self.config_entry.data:
user_input[CONF_EMAIL] = self.config_entry.data[CONF_EMAIL]
if CONF_PASSWORD in self.config_entry.data:
user_input[CONF_PASSWORD] = self.config_entry.data[CONF_PASSWORD]
if CONF_SECURITYCODE in self.config_entry.data:
user_input[CONF_SECURITYCODE] = self.config_entry.data[
if CONF_URL in self._config_entry.data:
user_input[CONF_URL] = self._config_entry.data[CONF_URL]
if CONF_EMAIL in self._config_entry.data:
user_input[CONF_EMAIL] = self._config_entry.data[CONF_EMAIL]
if CONF_PASSWORD in self._config_entry.data:
user_input[CONF_PASSWORD] = self._config_entry.data[CONF_PASSWORD]
if CONF_SECURITYCODE in self._config_entry.data:
user_input[CONF_SECURITYCODE] = self._config_entry.data[
CONF_SECURITYCODE
]
if CONF_OTPSECRET in self.config_entry.data:
user_input[CONF_OTPSECRET] = self.config_entry.data[CONF_OTPSECRET]
if CONF_OAUTH in self.config_entry.data:
user_input[CONF_OAUTH] = self.config_entry.data[CONF_OAUTH]
if CONF_OTPSECRET in self._config_entry.data:
user_input[CONF_OTPSECRET] = self._config_entry.data[CONF_OTPSECRET]
if CONF_OAUTH in self._config_entry.data:
user_input[CONF_OAUTH] = self._config_entry.data[CONF_OAUTH]
"""Ensure public_url ends with trailing slash"""
if CONF_PUBLIC_URL in self.config_entry.data:
if CONF_PUBLIC_URL in self._config_entry.data:
if not user_input[CONF_PUBLIC_URL].endswith("/"):
user_input[CONF_PUBLIC_URL] = user_input[CONF_PUBLIC_URL] + "/"

self.hass.config_entries.async_update_entry(
self.config_entry, data=user_input, options=self.config_entry.options
self._config_entry, data=user_input, options=self._config_entry.options
)
return self.async_create_entry(title="", data={})

Expand Down

0 comments on commit bf28415

Please sign in to comment.