Skip to content

Commit

Permalink
fix: save cookies_txt into configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Sep 29, 2020
1 parent 56e020f commit c74824e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .const import (
ALEXA_COMPONENTS,
CONF_ACCOUNTS,
CONF_COOKIES_TXT,
CONF_DEBUG,
CONF_EXCLUDE_DEVICES,
CONF_INCLUDE_DEVICES,
Expand Down Expand Up @@ -1012,6 +1013,7 @@ async def test_login_status(hass, config_entry, login) -> bool:
CONF_SCAN_INTERVAL: account[CONF_SCAN_INTERVAL].total_seconds()
if isinstance(account[CONF_SCAN_INTERVAL], timedelta)
else account[CONF_SCAN_INTERVAL],
CONF_COOKIES_TXT: account.get(CONF_COOKIES_TXT, ""),
},
)
hass.components.persistent_notification.async_create(
Expand Down
4 changes: 3 additions & 1 deletion custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ async def _test_login(self):
_LOGGER.debug("Testing login status: %s", login.status)
if login.status and login.status.get("login_successful"):
existing_entry = await self.async_set_unique_id(f"{email} - {login.url}")
self.config.pop(CONF_COOKIES_TXT)
if existing_entry:
self.hass.config_entries.async_update_entry(
existing_entry, data=self.config
Expand Down Expand Up @@ -541,6 +540,9 @@ def _update_schema_defaults(self) -> Any:
vol.Optional(
CONF_SCAN_INTERVAL, default=self.config.get(CONF_SCAN_INTERVAL, 60)
): int,
vol.Optional(
CONF_COOKIES_TXT, default=self.config.get(CONF_COOKIES_TXT, "")
): str,
},
)
return new_schema
Expand Down

0 comments on commit c74824e

Please sign in to comment.