Add MFA Capability to Tesla Integration (#53245)

* Adds MFA Capability to Tesla Integration

* Add "(Optional)" to MFA Code

* Update homeassistant/components/tesla/translations/de.json

Co-authored-by: J. Nick Koston <nick@koston.org>

* Update en.json

* Revert "Update en.json"

This reverts commit 825685c3a230f54094c10c86d7b82f4c81979064.

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
BreakingBread0 2021-07-27 01:46:49 +02:00 committed by GitHub
parent 3e08e50050
commit 20b66faa6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 4 deletions

View File

@ -21,6 +21,7 @@ from homeassistant.helpers.httpx_client import SERVER_SOFTWARE, USER_AGENT
from .const import (
CONF_EXPIRATION,
CONF_MFA,
CONF_WAKE_ON_START,
DEFAULT_SCAN_INTERVAL,
DEFAULT_WAKE_ON_START,
@ -99,6 +100,7 @@ class TeslaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
{
vol.Required(CONF_USERNAME, default=self.username): str,
vol.Required(CONF_PASSWORD): str,
vol.Optional(CONF_MFA): str,
}
)
@ -158,7 +160,9 @@ async def validate_input(hass: core.HomeAssistant, data):
password=data[CONF_PASSWORD],
update_interval=DEFAULT_SCAN_INTERVAL,
)
result = await controller.connect(test_login=True)
result = await controller.connect(
test_login=True, mfa_code=(data[CONF_MFA] if CONF_MFA in data else "")
)
config[CONF_TOKEN] = result["refresh_token"]
config[CONF_ACCESS_TOKEN] = result["access_token"]
config[CONF_EXPIRATION] = result[CONF_EXPIRATION]

View File

@ -1,6 +1,7 @@
"""Const file for Tesla cars."""
CONF_EXPIRATION = "expiration"
CONF_WAKE_ON_START = "enable_wake_on_start"
CONF_MFA = "mfa"
DOMAIN = "tesla"
DATA_LISTENER = "listener"
DEFAULT_SCAN_INTERVAL = 660

View File

@ -13,7 +13,8 @@
"user": {
"data": {
"username": "[%key:common::config_flow::data::email%]",
"password": "[%key:common::config_flow::data::password%]"
"password": "[%key:common::config_flow::data::password%]",
"mfa": "MFA Code (Optional)"
},
"description": "Please enter your information.",
"title": "Tesla - Configuration"

View File

@ -13,7 +13,8 @@
"user": {
"data": {
"password": "Password",
"username": "Email"
"username": "Email",
"mfa": "MFA Code (Optional)"
},
"description": "Please enter your information.",
"title": "Tesla - Configuration"