Skip to content

Commit

Permalink
fix: fix CONF_PUBLIC_URL saving (#2377)
Browse files Browse the repository at this point in the history
closes #2369
closes #2130
  • Loading branch information
danielbrunt57 authored Aug 2, 2024
1 parent 8da068c commit 9755e3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ async def async_setup(hass, config, discovery_info=None):
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_URL: account[CONF_URL],
CONF_EMAIL: account[CONF_EMAIL],
CONF_PASSWORD: account[CONF_PASSWORD],
CONF_URL: account[CONF_URL],
CONF_PUBLIC_URL: account[CONF_PUBLIC_URL],
CONF_INCLUDE_DEVICES: account[CONF_INCLUDE_DEVICES],
CONF_EXCLUDE_DEVICES: account[CONF_EXCLUDE_DEVICES],
CONF_SCAN_INTERVAL: account[CONF_SCAN_INTERVAL].total_seconds(),
Expand Down
31 changes: 29 additions & 2 deletions custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(self):
(vol.Required(CONF_PASSWORD), str),
(vol.Optional(CONF_OTPSECRET), str),
(vol.Optional(CONF_SECURITYCODE), str),
(vol.Optional(CONF_PUBLIC_URL), str),
(vol.Optional(CONF_INCLUDE_DEVICES, default=""), str),
(vol.Optional(CONF_EXCLUDE_DEVICES, default=""), str),
(vol.Optional(CONF_SCAN_INTERVAL, default=60), int),
Expand Down Expand Up @@ -151,6 +152,7 @@ async def async_step_user(self, user_input=None):
hass_url: str = get_url(self.hass, prefer_external=True)
except NoURLAvailableError:
hass_url = ""
DEFAULT_PUBLIC_URL = hass_url
self.proxy_schema = OrderedDict(
[
(
Expand Down Expand Up @@ -182,6 +184,13 @@ async def async_step_user(self, user_input=None):
),
str,
),
(
vol.Optional(
CONF_PUBLIC_URL,
default=self.config.get(CONF_PUBLIC_URL, DEFAULT_PUBLIC_URL),
),
str,
),
(
vol.Optional(
CONF_INCLUDE_DEVICES,
Expand Down Expand Up @@ -738,8 +747,10 @@ def _save_user_input_to_config(self, user_input=None) -> None:
self.config[CONF_EMAIL] = user_input[CONF_EMAIL]
if CONF_PASSWORD in user_input:
self.config[CONF_PASSWORD] = user_input[CONF_PASSWORD]
if CONF_HASS_URL in user_input:
self.config[CONF_HASS_URL] = user_input[CONF_HASS_URL]
if CONF_URL in user_input:
self.config[CONF_URL] = user_input[CONF_URL]
if CONF_PUBLIC_URL in user_input:
self.config[CONF_PUBLIC_URL] = user_input[CONF_PUBLIC_URL]
if CONF_SCAN_INTERVAL in user_input:
self.config[CONF_SCAN_INTERVAL] = (
user_input[CONF_SCAN_INTERVAL]
Expand Down Expand Up @@ -792,6 +803,13 @@ def _update_schema_defaults(self) -> Any:
CONF_OTPSECRET,
default=self.config.get(CONF_OTPSECRET, ""),
): str,
vol.Required(
CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
): str,
vol.Optional(
CONF_PUBLIC_URL,
default=self.config.get(CONF_PUBLIC_URL, DEFAULT_PUBLIC_URL),
): str,
vol.Optional(
CONF_INCLUDE_DEVICES,
default=self.config.get(CONF_INCLUDE_DEVICES, ""),
Expand Down Expand Up @@ -845,6 +863,15 @@ async def async_step_init(

self.options_schema = OrderedDict(
[
(
vol.Optional(
CONF_PUBLIC_URL,
default=self.config_entry.data.get(
CONF_PUBLIC_URL, DEFAULT_PUBLIC_URL
),
),
str,
),
(
vol.Optional(
CONF_INCLUDE_DEVICES,
Expand Down

0 comments on commit 9755e3f

Please sign in to comment.