From 48532e4abd8f6290b7adeb9bb13f418d29fe9220 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 2 Aug 2024 02:37:34 +0200 Subject: [PATCH 1/3] fix: use async_create for notification (#2380) closes #2382 --- custom_components/alexa_media/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/alexa_media/__init__.py b/custom_components/alexa_media/__init__.py index 67e3c4de..185dd919 100644 --- a/custom_components/alexa_media/__init__.py +++ b/custom_components/alexa_media/__init__.py @@ -27,6 +27,7 @@ ) import async_timeout from homeassistant import util +from homeassistant.components.persistent_notification import async_creat from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import ( CONF_EMAIL, @@ -1387,7 +1388,8 @@ async def test_login_status(hass, config_entry, login) -> bool: elaspsed_time: str = str(datetime.now() - login.stats.get("login_timestamp")) api_calls: int = login.stats.get("api_calls") message += f"Relogin required after {elaspsed_time} and {api_calls} api calls." - hass.components.persistent_notification.async_create( + # hass.components.persistent_notification.async_create( + async_create( title="Alexa Media Reauthentication Required", message=message, notification_id=f"alexa_media_{slugify(login.email)}{slugify(login.url[7:])}", From 8da068c4e52e5a6ffdeda375242c913da86fe532 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:38:03 -0700 Subject: [PATCH 2/3] fix: fix undefined TimeoutException (#2372) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- custom_components/alexa_media/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/alexa_media/__init__.py b/custom_components/alexa_media/__init__.py index 185dd919..77f33f18 100644 --- a/custom_components/alexa_media/__init__.py +++ b/custom_components/alexa_media/__init__.py @@ -46,6 +46,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.util import dt, slugify +from httpx import TimeoutException import voluptuous as vol from .alexa_entity import AlexaEntityData, get_entity_data, parse_alexa_entities From 9755e3fa8552355ec7d7eee08c65a542ce43f379 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:38:44 -0700 Subject: [PATCH 3/3] fix: fix CONF_PUBLIC_URL saving (#2377) closes #2369 closes #2130 --- custom_components/alexa_media/__init__.py | 3 +- custom_components/alexa_media/config_flow.py | 31 ++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/custom_components/alexa_media/__init__.py b/custom_components/alexa_media/__init__.py index 77f33f18..c2198b9d 100644 --- a/custom_components/alexa_media/__init__.py +++ b/custom_components/alexa_media/__init__.py @@ -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(), diff --git a/custom_components/alexa_media/config_flow.py b/custom_components/alexa_media/config_flow.py index 8b8eb9bf..35eae321 100644 --- a/custom_components/alexa_media/config_flow.py +++ b/custom_components/alexa_media/config_flow.py @@ -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), @@ -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( [ ( @@ -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, @@ -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] @@ -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, ""), @@ -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,