mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
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:
parent
3e08e50050
commit
20b66faa6d
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -30,4 +30,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
"user": {
|
||||
"data": {
|
||||
"password": "Password",
|
||||
"username": "Email"
|
||||
"username": "Email",
|
||||
"mfa": "MFA Code (Optional)"
|
||||
},
|
||||
"description": "Please enter your information.",
|
||||
"title": "Tesla - Configuration"
|
||||
|
Loading…
x
Reference in New Issue
Block a user