Skip to content

Commit

Permalink
Merge branch 'master' of github.com:eifinger/homeassistant-config
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Nov 30, 2020
2 parents dd132a1 + c2c33d1 commit 4ecc0e5
Show file tree
Hide file tree
Showing 32 changed files with 323 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/homeassistant-installed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
- name: Create secrets.yaml
run: mv travis_secrets.yaml secrets.yaml
- name: Home Assistant Check Installed
uses: "docker://homeassistant/home-assistant:0.118.3"
uses: "docker://homeassistant/home-assistant:0.118.4"
with:
args: python -m homeassistant --config . --script check_config --info all
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ version: '2.1'
services:
homeassistant:
container_name: homeassistant
image: homeassistant/home-assistant:0.118.3
image: homeassistant/home-assistant:0.118.4
volumes:
- /home/admin/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nBitte Verifizierungs Methode auswählen. (z.B., `0` oder `1`) \n{message}",
"title": "Alexa Media Player - Verifizierungs Methode"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA Code"
Expand All @@ -53,6 +60,7 @@
"email": "Email Adresse",
"exclude_devices": "Ausgeschlossene Geräte (komma getrennnt)",
"include_devices": "Eingebundene Geräte (komma getrennnt)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Passwort",
"scan_interval": "Sekunden zwischen den Scans",
"securitycode": "2FA Code (empfohlen, um Anmeldeprobleme zu vermeiden)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nPlease select verification method by number. (e.g., `0` or `1`) \n{message}",
"title": "Alexa Media Player - Verification Method"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA Code"
Expand All @@ -53,6 +60,7 @@
"email": "Email Address",
"exclude_devices": "Excluded device (comma separated)",
"include_devices": "Included device (comma separated)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Password",
"scan_interval": "Seconds between scans",
"securitycode": "2FA Code (recommended to avoid login issues)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nSeleccione el método de verificación por número. (e.g., `0` or `1`) \n{message}",
"title": "Alexa Media Player - Método de verificación"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA Code"
Expand All @@ -53,6 +60,7 @@
"email": "Dirección de correo electrónico",
"exclude_devices": "Dispositivo excluido (separado por comas)",
"include_devices": "Dispositivo incluido (separado por comas)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Contraseña",
"scan_interval": "Segundos entre escaneos",
"securitycode": "Código 2FA (recomendado para evitar problemas de inicio de sesión)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nVeuillez sélectionner la méthode de vérification par numéro. (exemple., `0` ou `1`) \n{message}",
"title": "Alexa Media Player - Méthode de vérification"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA Code"
Expand All @@ -53,6 +60,7 @@
"email": "Adresse Email",
"exclude_devices": "Appareil exclu (séparé par des virgules)",
"include_devices": "Appareil inclus (séparé par des virgules)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Mot de passe",
"scan_interval": "Secondes entre les analyses",
"securitycode": "Code 2FA (recommandé pour éviter les problèmes de connexion)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nPrego selezionare un metodo di verifica. (e.g., `0` or `1`) \n{message}",
"title": "Alexa Media Player - Metodi di Verifica"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "Codice autenticazione a 2 fattori (2FA)"
Expand All @@ -53,6 +60,7 @@
"email": "Indirizzo email",
"exclude_devices": "Dispositivi da escludere (separati da virgola)",
"include_devices": "Dispositivi da includere (separati da virgola)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Password",
"scan_interval": "Tempo in secondi fra le scansioni",
"securitycode": "2FA Code (recommended to avoid login issues)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nVelg bekreftelsesmetode etter nummer. (f.eks. \"0\" eller \"1\") \n{message}",
"title": "Alexa Media Player - Bekreftelsesmetode"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA Kode"
Expand All @@ -53,6 +60,7 @@
"email": "Epostadresse",
"exclude_devices": "Ekskludert enhet (kommaseparert)",
"include_devices": "Inkluder enhet (kommaseparert)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Passord",
"scan_interval": "Sekunder mellom skanninger",
"securitycode": "2FA-kode (anbefales for å unngå påloggingsproblemer)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nSelecteer de verificatiemethode (bv.`0` of `1`) \n{message}",
"title": "Alexa Media Player - Verificatiemethode"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "Verificatiecode"
Expand All @@ -53,6 +60,7 @@
"email": "E-mailadres",
"exclude_devices": "Apparaten uitsluiten (Scheiding: komma)",
"include_devices": "Apparaten toevoegen (Scheiding: komma)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Paswoord",
"scan_interval": "Aantal seconden tussen scans",
"securitycode": "2FA Code (recommended to avoid login issues)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nWybierz metodę weryfikacji. (np., `0` lub `1`) \n{message}",
"title": "Alexa Media Player — metoda weryfikacji"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "Kod uwierzytelniania dwuskładnikowego"
Expand All @@ -53,6 +60,7 @@
"email": "Adres email",
"exclude_devices": "Wykluczone urządzenia (oddzielone przecinkami)",
"include_devices": "Dodawane urządzenia (oddzielone przecinkami)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Hasło",
"scan_interval": "Interwał skanowania (sekundy)",
"securitycode": "Kod uwierzytelniania dwuskładnikowego (zalecany w celu uniknięcia problemów z logowaniem)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}**\nПожалуйста, выберите способ проверки по номеру. (например, \" 0 \" или \" 1`)\n{message}",
"title": "Alexa Media Player - Метод проверки"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2-факторная авторизация"
Expand All @@ -53,6 +60,7 @@
"email": "Адрес электронной почты",
"exclude_devices": "Исключенные устройства (через запятую)",
"include_devices": "Включенные устройства (разделенное запятыми)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "Пароль",
"scan_interval": "Секунды между сканированиями",
"securitycode": "2FA Code (recommended to avoid login issues)",
Expand Down
8 changes: 8 additions & 0 deletions custom_components/alexa_media/.translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"description": "**{email} - alexa.{url}** \nPlease select verification method by number. (e.g., `0` or `1`) \n{message}",
"title": "Alexa Media Player - 验证方法"
},
"totp_register": {
"data": {
"registered": "OTP from the Built-in 2FA App Key confirmed successfully."
},
"description": "**{email} - alexa.{url}** \nHave you successfully confirmed an OTP from the Built-in 2FA App Key with Amazon? \n >OTP Code {message}",
"title": "Alexa Media Player - OTP Confirmation"
},
"twofactor": {
"data": {
"securitycode": "2FA代码"
Expand All @@ -53,6 +60,7 @@
"email": "电子邮件地址",
"exclude_devices": "Excluded device (comma separated)",
"include_devices": "Included device (comma separated)",
"otp_secret": "Built-in 2FA App Key (automatically generate 2FA Codes)",
"password": "密码",
"scan_interval": "Seconds between scans",
"securitycode": "2FA Code (recommended to avoid login issues)",
Expand Down
40 changes: 33 additions & 7 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
CONF_DEBUG,
CONF_EXCLUDE_DEVICES,
CONF_INCLUDE_DEVICES,
CONF_OTPSECRET,
CONF_QUEUE_DELAY,
DATA_ALEXAMEDIA,
DATA_LISTENER,
Expand Down Expand Up @@ -134,6 +135,7 @@ async def async_setup(hass, config, discovery_info=None):
CONF_SCAN_INTERVAL: account[
CONF_SCAN_INTERVAL
].total_seconds(),
CONF_OTPSECRET: account.get(CONF_OTPSECRET, ""),
},
)
entry_found = True
Expand All @@ -152,6 +154,7 @@ async def async_setup(hass, config, discovery_info=None):
CONF_INCLUDE_DEVICES: account[CONF_INCLUDE_DEVICES],
CONF_EXCLUDE_DEVICES: account[CONF_EXCLUDE_DEVICES],
CONF_SCAN_INTERVAL: account[CONF_SCAN_INTERVAL].total_seconds(),
CONF_OTPSECRET: account.get(CONF_OTPSECRET, ""),
},
)
)
Expand Down Expand Up @@ -179,7 +182,12 @@ async def relogin(event=None) -> None:
)
if login_obj is None:
login_obj = AlexaLogin(
url, email, password, hass.config.path, account.get(CONF_DEBUG)
url,
email,
password,
hass.config.path,
account.get(CONF_DEBUG),
account.get(CONF_OTPSECRET, ""),
)
hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"login_obj"
Expand Down Expand Up @@ -239,7 +247,14 @@ async def login_success(event=None) -> None:
)
login = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get(
"login_obj",
AlexaLogin(url, email, password, hass.config.path, account.get(CONF_DEBUG)),
AlexaLogin(
url,
email,
password,
hass.config.path,
account.get(CONF_DEBUG),
account.get(CONF_OTPSECRET, ""),
),
)
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"] = login
await login.login(cookies=await login.load_cookie())
Expand Down Expand Up @@ -459,6 +474,7 @@ async def async_update_data():
)

hass.data[DATA_ALEXAMEDIA]["accounts"][email]["new_devices"] = False
await login_obj.save_cookiefile()

@_catch_login_errors
async def process_notifications(login_obj, raw_notifications=None):
Expand Down Expand Up @@ -1011,6 +1027,7 @@ async def close_connections(hass, email: Text) -> None:
return
account_dict = hass.data[DATA_ALEXAMEDIA]["accounts"][email]
login_obj = account_dict["login_obj"]
await login_obj.save_cookiefile()
await login_obj.close()
_LOGGER.debug(
"%s: Connection closed: %s", hide_email(email), login_obj.session.closed
Expand Down Expand Up @@ -1043,6 +1060,19 @@ async def test_login_status(hass, config_entry, login) -> bool:
return True
account = config_entry.data
_LOGGER.debug("Logging in: %s %s", obfuscate(account), in_progess_instances(hass))
_LOGGER.debug("Login stats: %s", login.stats)
message: Text = (
"Reauthenticate on the [Integrations](/config/integrations) page. "
)
if login.stats.get("login_timestamp") != datetime(1, 1, 1):
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(
title="Alexa Media Reauthentication Required",
message=message,
notification_id="alexa_media_relogin_required",
)
flow = hass.data[DATA_ALEXAMEDIA]["config_flows"].get(
f"{account[CONF_EMAIL]} - {account[CONF_URL]}"
)
Expand Down Expand Up @@ -1075,11 +1105,7 @@ async def test_login_status(hass, config_entry, login) -> bool:
if isinstance(account[CONF_SCAN_INTERVAL], timedelta)
else account[CONF_SCAN_INTERVAL],
CONF_COOKIES_TXT: account.get(CONF_COOKIES_TXT, ""),
CONF_OTPSECRET: account.get(CONF_OTPSECRET, ""),
},
)
hass.components.persistent_notification.async_create(
title="Alexa Media Reauthentication Required",
message=("Reauthenticate on the [Integrations](/config/integrations) page."),
notification_id="alexa_media_relogin_required",
)
return False
Loading

0 comments on commit 4ecc0e5

Please sign in to comment.