Skip to content

Commit

Permalink
HA & HACS update #14 #16
Browse files Browse the repository at this point in the history
BeardedTinker committed Sep 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 51bd5ea commit 7e58925
Showing 2,630 changed files with 21,070 additions and 17,564 deletions.
2 changes: 1 addition & 1 deletion .HA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.8.1
2024.9.1
4 changes: 2 additions & 2 deletions automations/system/synology_temp_critical.yaml
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ id: fbdf3f33-5749-453a-aac9-c1501f28ba77
trigger:
- platform: numeric_state
entity_id: sensor.ebroz920_temperature
above: 68
for: "0:07:00"
above: 70
for: "0:12:00"

action:
- service: script.notify_engine
2 changes: 1 addition & 1 deletion automations/utilities/ac_off.yaml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ condition:
conditions:
- condition: state
alias: "AC is on"
entity_id: binary_sensor.ac_on
entity_id: input_boolean.ac_on
state: 'on'

action:
2 changes: 1 addition & 1 deletion automations/utilities/ac_on.yaml
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ condition:
state: 'on'
- condition: state
alias: "AC is off"
entity_id: binary_sensor.ac_on
entity_id: input_boolean.ac_on
state: 'off'


80 changes: 72 additions & 8 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
from datetime import datetime, timedelta
from json import JSONDecodeError, loads
import logging
import os
import time
from typing import Optional

@@ -25,6 +26,7 @@
hide_serial,
obfuscate,
)
from alexapy.helpers import delete_cookie as alexapy_delete_cookie
import async_timeout
from homeassistant import util
from homeassistant.components.persistent_notification import (
@@ -1242,8 +1244,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)
@@ -1286,14 +1298,19 @@ async def http2_error_handler(message):


async def async_unload_entry(hass, entry) -> bool:
"""Unload a config entry."""
"""Unload a config entry"""
email = entry.data["email"]
_LOGGER.debug("Attempting to unload entry for %s", hide_email(email))
login_obj = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"]
_LOGGER.debug("Unloading entry: %s", hide_email(email))
for component in ALEXA_COMPONENTS + DEPENDENT_ALEXA_COMPONENTS:
_LOGGER.debug("Forwarding unload entry to %s", component)
await hass.config_entries.async_forward_entry_unload(entry, component)
# notify has to be handled manually as the forward does not work yet
await notify_async_unload_entry(hass, entry)
try:
if component == "notify":
await notify_async_unload_entry(hass, entry)
else:
_LOGGER.debug("Forwarding unload entry to %s", component)
await hass.config_entries.async_forward_entry_unload(entry, component)
except Exception as ex:
_LOGGER.error("Error unloading: %s", component)
await close_connections(hass, email)
for listener in hass.data[DATA_ALEXAMEDIA]["accounts"][email][DATA_LISTENER]:
listener()
@@ -1338,6 +1355,53 @@ async def async_unload_entry(hass, entry) -> bool:
return True


async def async_remove_entry(hass, entry) -> bool:
"""Handle removal of an entry."""
email = entry.data["email"]
obfuscated_email = hide_email(email)
_LOGGER.debug("Removing config entry: %s", hide_email(email))
login_obj = AlexaLogin(
url="",
email=email,
password="",
outputpath=hass.config.path,
)
# Delete cookiefile
cookiefile = hass.config.path(f".storage/{DOMAIN}.{email}.pickle")
obfuscated_cookiefile = hass.config.path(
f".storage/{DOMAIN}.{obfuscated_email}.pickle"
)
if callable(getattr(AlexaLogin, "delete_cookiefile", None)):
try:
await login_obj.delete_cookiefile()
_LOGGER.debug("Cookiefile %s deleted.", obfuscated_cookiefile)
except Exception as ex:
_LOGGER.error(
"delete_cookiefile() exception: %s;"
" Manually delete cookiefile before re-adding the integration: %s",
ex,
obfuscated_cookiefile,
)
else:
if os.path.exists(cookiefile):
try:
await alexapy_delete_cookie(cookiefile)
_LOGGER.debug(
"Successfully deleted cookiefile: %s", obfuscated_cookiefile
)
except (OSError, EOFError, TypeError, AttributeError) as ex:
_LOGGER.error(
"alexapy_delete_cookie() exception: %s;"
" Manually delete cookiefile before re-adding the integration: %s",
ex,
obfuscated_cookiefile,
)
else:
_LOGGER.error("Cookiefile not found: %s", obfuscated_cookiefile)
_LOGGER.debug("Config entry %s removed.", obfuscated_email)
return True


async def close_connections(hass, email: str) -> None:
"""Clear open aiohttp connections for email."""
if (
5 changes: 3 additions & 2 deletions custom_components/alexa_media/alexa_entity.py
Original file line number Diff line number Diff line change
@@ -350,10 +350,11 @@ def parse_temperature_from_coordinator(
coordinator: DataUpdateCoordinator, entity_id: str
) -> Optional[str]:
"""Get the temperature of an entity from the coordinator data."""
value = parse_value_from_coordinator(
temperature = parse_value_from_coordinator(
coordinator, entity_id, "Alexa.TemperatureSensor", "temperature"
)
return value.get("value") if value and "value" in value else None
_LOGGER.debug("parse_temperature_from_coordinator: %s", temperature)
return temperature


def parse_air_quality_from_coordinator(
13 changes: 9 additions & 4 deletions custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
@@ -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
@@ -642,8 +645,9 @@ 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(
f"alexa_media_{slugify(email)}{slugify(login.url[7:])}"
async_dismiss_persistent_notification(
self.hass,
notification_id=f"alexa_media_{slugify(email)}{slugify(login.url[7:])}",
)
if not self.hass.data[DATA_ALEXAMEDIA]["accounts"].get(
self.config[CONF_EMAIL]
@@ -695,8 +699,9 @@ 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(
f"alexa_media_{slugify(email)}{slugify(login.url[7:])}"
async_dismiss_persistent_notification(
self.hass,
notification_id=f"alexa_media_{slugify(email)}{slugify(login.url[7:])}",
)
return self.async_abort(reason="login_failed")
new_schema = self._update_schema_defaults()
177 changes: 176 additions & 1 deletion custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
PERCENTAGE,
)

__version__ = "4.12.7"
__version__ = "4.13.1"
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"
@@ -139,3 +139,178 @@
ALEXA_ICON_DEFAULT = "mdi:molecule"

UPLOAD_PATH = "www/alexa_tts"

# Note: Some of these are likely wrong
MODEL_IDS = {
"A10A33FOX2NUBK": "Echo Spot (Gen1)",
"A10L5JEZTKKCZ8": "Vobot Bunny",
"A11QM4H9HGV71H": "Echo Show 5 (Gen3)",
"A12GXV8XMS007S": "Fire TV (Gen1)",
"A12IZU8NMHSY5U": "Generic Device",
"A132LT22WVG6X5": "Samsung Soundbar Q700A",
"A13B2WB920IZ7X": "Samsung HW-Q70T Soundbar",
"A13W6HQIHKEN3Z": "Echo Auto",
"A14ZH95E6SE9Z1": "Bose Home Speaker 300",
"A15996VY63BQ2D": "Echo Show 8 (Gen2)",
"A15ERDAKK5HQQG": "Sonos",
"A15QWUTQ6FSMYX": "Echo Buds (Gen2)",
"A16MZVIFVHX6P6": "Generic Echo",
"A17LGWINFBUTZZ": "Anker Roav Viva",
"A18BI6KPKDOEI4": "Ecobee4",
"A18O6U1UQFJ0XK": "Echo Plus (Gen2)",
"A18TCD9FP10WJ9": "Orbi Voice",
"A18X8OBWBCSLD8": "Samsung Soundbar",
"A195TXHV1M5D4A": "Echo Auto",
"A1C66CX2XD756O": "Fire Tablet HD",
"A1EIANJ7PNB0Q7": "Echo Show 15 (Gen1)",
"A1ENT81UXFMNNO": "Unknown",
"A1ETW4IXK2PYBP": "Talk to Alexa",
"A1F1F76XIW4DHQ": "Unknown TV",
"A1F8D55J0FWDTN": "Fire TV (Toshiba)",
"A1H0CMF1XM0ZP4": "Bose SoundTouch 30",
"A1J16TEDOYCZTN": "Fire Tablet",
"A1JJ0KFC4ZPNJ3": "Echo Input",
"A1L4KDRIILU6N9": "Sony Speaker",
"A1LOQ8ZHF4G510": "Samsung Soundbar Q990B",
"A1M0A9L9HDBID3": "One-Link Safe and Sound",
"A1MUORL8FP149X": "Unknown",
"A1N9SW0I0LUX5Y": "Ford/Lincoln Alexa App",
"A1NL4BVLQ4L3N3": "Echo Show (Gen1)",
"A1NQ0LXWBGVQS9": "2021 Samsung QLED TV",
"A1P31Q3MOWSHOD": "Zolo Halo Speaker",
"A1P7E7V3FCZKU6": "Fire TV (Gen3)",
"A1Q69AKRWLJC0F": "TV",
"A1Q7QCGNMXAKYW": "Generic Tablet",
"A1QKZ9D0IJY332": "Samsung TV 2020-U",
"A1RABVCI4QCIKC": "Echo Dot (Gen3)",
"A1RTAM01W29CUP": "Windows App",
"A1SCI5MODUBAT1": "Pioneer DMH-W466NEX",
"A1TD5Z1R8IWBHA": "Tablet",
"A1VGB7MHSIEYFK": "Fire TV Cube Gen3",
"A1W2YILXTG9HA7": "Nextbase 522GW Dashcam",
"A1W46V57KES4B5": "Cable TV box Brazil",
"A1WZKXFLI43K86": "Fire TV Stick MAX",
"A1XWJRHALS1REP": "Echo Show 5 (Gen2)",
"A1Z88NGR2BK6A2": "Echo Show 8 (Gen1)",
"A25EC4GIHFOCSG": "Unrecognized Media Player",
"A25OJWHZA1MWNB": "2021 Samsung QLED TV",
"A265XOI9586NML": "Fire TV Stick",
"A27VEYGQBW3YR5": "Echo Link",
"A2A3XFQ1AVYLHZ": "SONY WF-1000XM5",
"A2BRQDVMSZD13S": "SURE Universal Remote",
"A2C8J6UHV0KFCV": "Alexa Gear",
"A2DS1Q2TPDJ48U": "Echo Dot Clock (Gen5)",
"A2E0SNTXJVT7WK": "Fire TV (Gen2)",
"A2E5N6DMWCW8MZ": "Brilliant Smart Switch",
"A2EZ3TS0L1S2KV": "Sonos Beam",
"A2GFL5ZMWNE0PX": "Fire TV (Gen3)",
"A2H4LV5GIZ1JFT": "Echo Dot Clock (Gen4)",
"A2HZENIFNYTXZD": "Facebook Portal",
"A2I0SCCU3561Y8": "Samsung Soundbar Q800A",
"A2IS7199CJBT71": "TV",
"A2IVLV5VM2W81": "Alexa Mobile Voice iOS",
"A2J0R2SD7G9LPA": "Lenovo SmartTab M10",
"A2JKHJ0PX4J3L3": "Fire TV Cube (Gen2)",
"A2LH725P8DQR2A": "Fabriq Riff",
"A2LWARUGJLBYEW": "Fire TV Stick (Gen2)",
"A2M35JJZWCQOMZ": "Echo Plus (Gen1)",
"A2M4YX06LWP8WI": "Fire Tablet",
"A2N49KXGVA18AR": "Fire Tablet HD 10 Plus",
"A2OSP3UA4VC85F": "Sonos",
"A2R2GLZH1DFYQO": "Zolo Halo Speaker",
"A2RU4B77X9R9NZ": "Echo Link Amp",
"A2TF17PFR55MTB": "Alexa Mobile Voice Android",
"A2TTLILJHVNI9X": "LG TV",
"A2U21SRK4QGSE1": "Echo Dot Clock (Gen4)",
"A2UONLFQW0PADH": "Echo Show 8 (Gen3)",
"A2V9UEGZ82H4KZ": "Fire Tablet HD 10",
"A2VAXZ7UNGY4ZH": "Wyze Headphones",
"A2WFDCBDEXOXR8": "Bose Soundbar 700",
"A2WN1FJ2HG09UN": "Ultimate Alexa App",
"A2X8WT9JELC577": "Ecobee5",
"A2XPGY5LRKB9BE": "Fitbit Versa 2",
"A2Y04QPFCANLPQ": "Bose QuietComfort 35 II",
"A303PJF6ISQ7IC": "Echo Auto",
"A30YDR2MK8HMRV": "Echo (Gen3)",
"A31DTMEEVDDOIV": "Fire TV Stick Lite",
"A324YMIUSWQDGE": "Samsung 8K TV",
"A32DDESGESSHZA": "Echo Dot (Gen3)",
"A32DOYMUN6DTXA": "Echo Dot (Gen3)",
"A339L426Y220I4": "Teufel Radio",
"A347G2JC8I4HC7": "Roav Car Charger Pro",
"A37CFAHI1O0CXT": "Logitech Blast",
"A37M7RU8Z6ZFB": "Garmin Speak",
"A37SHHQ3NUL7B5": "Bose Home Speaker 500",
"A38949IHXHRQ5P": "Echo Tap",
"A38BPK7OW001EX": "Raspberry Alexa",
"A38EHHIB10L47V": "Fire Tablet HD 8",
"A39BU42XNMN516": "Generic Device",
"A3B50IC5QPZPWP": "Polk Command Bar",
"A3B5K1G3EITBIF": "Facebook Portal",
"A3BRT6REMPQWA8": "Bose Home Speaker 450",
"A3BW5ZVFHRCQPO": "BMW Alexa Integration",
"A3C9PE6TNYLTCH": "Speaker Group",
"A3CY98NH016S5F": "Facebook Portal Mini",
"A3D4YURNTARP5K": "Facebook Portal TV",
"A3EH2E0YZ30OD6": "Echo Spot (Gen2)",
"A3EVMLQTU6WL1W": "Fire TV (GenX)",
"A3F1S88NTZZXS9": "Dash Wand",
"A3FX4UWTP28V1P": "Echo (Gen3)",
"A3GFRGUNIGG1I5": "Samsung TV QN50Q60CAGXZD",
"A3HF4YRA2L7XGC": "Fire TV Cube",
"A3IYPH06PH1HRA": "Echo Frames",
"A3K69RS3EIMXPI": "Hisense Smart TV",
"A3KULB3NQN7Z1F": "Unknown TV",
"A3L0T0VL9A921N": "Fire Tablet HD 8",
"A3NPD82ABCPIDP": "Sonos Beam",
"A3QPPX1R9W5RJV": "Fabriq Chorus",
"A3QS1XP2U6UJX9": "SONY WF-1000XM4",
"A3R9S4ZZECZ6YL": "Fire Tablet HD 10",
"A3RBAYBE7VM004": "Echo Studio",
"A3RCTOK2V0A4ZG": "LG TV",
"A3RMGO6LYLH7YN": "Echo Dot (Gen4)",
"A3S5BH2HU6VAYF": "Echo Dot (Gen2)",
"A3SSG6GR8UU7SN": "Echo Sub",
"A3SSWQ04XYPXBH": "Generic Tablet",
"A3TCJ8RTT3NVI7": "Alexa Listens",
"A3VRME03NAXFUB": "Echo Flex",
"A4ZP7ZC4PI6TO": "Echo Show 5 (Gen1)",
"A4ZXE0RM7LQ7A": "Echo Dot (Gen5)",
"A52ARKF0HM2T4": "Facebook Portal+",
"A6SIQKETF3L2E": "Unknown Device",
"A7WXQPH584YP": "Echo (Gen2)",
"A81PNL0A63P93": "Home Remote",
"A8DM4FYR6D3HT": "TV",
"AA1IN44SS3X6O": "Ecobee Thermostat Premium",
"AB72C64C86AW2": "Echo (Gen1)",
"ABJ2EHL7HQT4L": "Unknown Amplifier",
"ADVBD696BHNV5": "Fire TV Stick (Gen1)",
"AE7X7Z227NFNS": "HiMirror Mini",
"AF473ZSOIRKFJ": "Onkyo VC-PX30",
"AFF50AL5E3DIU": "Fire TV (Insignia)",
"AFF5OAL5E3DIU": "Fire TV",
"AGHZIK8D6X7QR": "Fire TV",
"AHJYKVA63YCAQ": "Sonos",
"AIPK7MM90V7TB": "Echo Show 10 (Gen3)",
"AKKLQD9FZWWQS": "Jabra Elite",
"AKNO1N0KSFN8L": "Echo Dot (Gen1)",
"AKO51L5QAQKL2": "Alexa Jams",
"AKPGW064GI9HE": "Fire TV Stick 4K (Gen3)",
"ALT9P69K6LORD": "Echo Auto",
"AMCZ48H33RCDF": "Samsung HW-Q910B 9.1.2 ch Soundbar",
"AN630UQPG2CA4": "Fire TV (Toshiba)",
"AO6HHP9UE6EOF": "Unknown Media Device",
"AP1F6KUH00XPV": "Stereo/Subwoofer Pair",
"AP4RS91ZQ0OOI": "Fire TV (Toshiba)",
"APHEAY6LX7T13": "Samsung Smart Refrigerator",
"AQCGW9PSYWRF": "TV",
"AR6X0XNIME80V": "Unknown TV",
"ASQZWP4GPYUT7": "Echo Pop",
"ATNLRCEBX3W4P": "Generic Tablet",
"AUPUQSVCVHXP0": "Ecobee Switch+",
"AVD3HM0HOJAAL": "Sonos",
"AVE5HX13UR5NO": "Logitech Zero Touch",
"AVN2TMX8MU2YM": "Bose Home Speaker 500",
"AVU7CPPF2ZRAS": "Fire Tablet HD 8",
"AWZZ5CVHX2CD": "Echo Show (Gen2)",
}
4 changes: 2 additions & 2 deletions custom_components/alexa_media/manifest.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,6 @@
"iot_class": "cloud_polling",
"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"
"requirements": ["alexapy==1.29.2", "packaging>=20.3", "wrapt>=1.14.0"],
"version": "4.13.1"
}
Loading

0 comments on commit 7e58925

Please sign in to comment.