Skip to content

Commit

Permalink
Merge branch 'dev' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse authored Aug 24, 2024
2 parents 00eb39a + f7ee01f commit 866f136
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ assignees: ""

**System details**

- Home-assistant (version):
- alexa_media (version from `const.py` or HA startup):
- alexapy (version from `pip show alexapy` or HA startup):
- Amazon [2FA is enabled](https://github.com/alandtse/alexa_media_player/wiki/Configuration#enable-two-factor-authentication-for-your-amazon-account) (y/n). <!---We will not debug login issues if unanswered--->:
- Home Assistant version:
- alexa_media version (from `const.py` or HA startup log):
- alexapy version (from `pip show alexapy` in homeasssistant container or HA startup log):
- Is Amazon [2FA/2SV enabled](https://github.com/alandtse/alexa_media_player/wiki/Configuration#enable-two-factor-authentication-for-your-amazon-account) <!---We will not debug login issues if unanswered---> (y/n):
- Amazon Domain:

**Logs**
**Debug Logs (alexa_media & alexapy)**
Please provide [logs](https://github.com/alandtse/alexa_media_player/wiki/FAQ#how-do-i-enable-debug-logging-for-the-component).

**Additional context**
Expand Down
32 changes: 30 additions & 2 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime, timedelta
from json import JSONDecodeError, loads
import logging
import os
import time
from typing import Optional

Expand Down Expand Up @@ -1242,8 +1243,18 @@ async def http2_error_handler(message):
_LOGGER.debug("Setting up Alexa devices for %s", hide_email(login_obj.email))
config = config_entry.data
email = config.get(CONF_EMAIL)
include = config.get(CONF_INCLUDE_DEVICES)
exclude = config.get(CONF_EXCLUDE_DEVICES)
include = (
cv.ensure_list_csv(config[CONF_INCLUDE_DEVICES])
if config[CONF_INCLUDE_DEVICES]
else ""
)
_LOGGER.debug("include: %s", include)
exclude = (
cv.ensure_list_csv(config[CONF_EXCLUDE_DEVICES])
if config[CONF_EXCLUDE_DEVICES]
else ""
)
_LOGGER.debug("exclude: %s", exclude)
scan_interval: float = (
config.get(CONF_SCAN_INTERVAL).total_seconds()
if isinstance(config.get(CONF_SCAN_INTERVAL), timedelta)
Expand Down Expand Up @@ -1288,6 +1299,7 @@ async def http2_error_handler(message):
async def async_unload_entry(hass, entry) -> bool:
"""Unload a config entry."""
email = entry.data["email"]
login_obj = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"]
_LOGGER.debug("Attempting to unload entry for %s", hide_email(email))
for component in ALEXA_COMPONENTS + DEPENDENT_ALEXA_COMPONENTS:
_LOGGER.debug("Forwarding unload entry to %s", component)
Expand Down Expand Up @@ -1329,6 +1341,22 @@ async def async_unload_entry(hass, entry) -> bool:
_LOGGER.debug("Removing alexa_media data structure")
if hass.data.get(DATA_ALEXAMEDIA):
hass.data.pop(DATA_ALEXAMEDIA)
# Delete cookiefile
if callable(getattr(AlexaLogin, "delete_cookiefile", None)):
try:
await login_obj.delete_cookiefile()
_LOGGER.debug("Deleted cookiefile")
except Exception as ex:
_LOGGER.error(
"Failed to delete cookiefile: %s",
ex,
)
else:
_LOGGER.warn(
"Could not remove cookiefile: /config/.storage/alexa_media.%s.pickle."
" Please manually delete the file.",
email,
)
else:
_LOGGER.debug(
"Unable to remove alexa_media data structure: %s",
Expand Down
7 changes: 5 additions & 2 deletions custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
)
from homeassistant import config_entries
from homeassistant.components.http.view import HomeAssistantView
from homeassistant.components.persistent_notification import (
async_dismiss as async_dismiss_persistent_notification,
)
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_URL
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult, UnknownFlow
Expand Down Expand Up @@ -642,7 +645,7 @@ async def _test_login(self):
"alexa_media_relogin_success",
event_data={"email": hide_email(email), "url": login.url},
)
self.hass.components.persistent_notification.async_dismiss(
async_dismiss_persistent_notification(
f"alexa_media_{slugify(email)}{slugify(login.url[7:])}"
)
if not self.hass.data[DATA_ALEXAMEDIA]["accounts"].get(
Expand Down Expand Up @@ -695,7 +698,7 @@ async def _test_login(self):
if login.status and (login.status.get("login_failed")):
_LOGGER.debug("Login failed: %s", login.status.get("login_failed"))
await login.close()
self.hass.components.persistent_notification.async_dismiss(
async_dismiss_persistent_notification(
f"alexa_media_{slugify(email)}{slugify(login.url[7:])}"
)
return self.async_abort(reason="login_failed")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
PERCENTAGE,
)

__version__ = "4.12.7"
__version__ = "4.12.11"
PROJECT_URL = "https://github.com/alandtse/alexa_media_player/"
ISSUE_URL = f"{PROJECT_URL}issues"
NOTIFY_URL = f"{PROJECT_URL}wiki/Configuration%3A-Notification-Component#use-the-notifyalexa_media-service"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"issue_tracker": "https://github.com/alandtse/alexa_media_player/issues",
"loggers": ["alexapy", "authcaptureproxy"],
"requirements": ["alexapy==1.28.2", "packaging>=20.3", "wrapt>=1.14.0"],
"version": "4.12.7"
"version": "4.12.11"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "alexa_media_player"
version = "4.12.7"
version = "4.12.11"
description = "This is a custom component to allow control of Amazon Alexa devices in [Homeassistant](https://home-assistant.io) using the unofficial Alexa API."
authors = [
"Keaton Taylor <[email protected]>",
Expand Down

0 comments on commit 866f136

Please sign in to comment.