mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use oauthv3 for Tesla (#45766)
This commit is contained in:
parent
538df17a28
commit
cdd78316c4
@ -103,6 +103,8 @@ async def async_setup(hass, base_config):
|
|||||||
_update_entry(
|
_update_entry(
|
||||||
email,
|
email,
|
||||||
data={
|
data={
|
||||||
|
CONF_USERNAME: email,
|
||||||
|
CONF_PASSWORD: password,
|
||||||
CONF_ACCESS_TOKEN: info[CONF_ACCESS_TOKEN],
|
CONF_ACCESS_TOKEN: info[CONF_ACCESS_TOKEN],
|
||||||
CONF_TOKEN: info[CONF_TOKEN],
|
CONF_TOKEN: info[CONF_TOKEN],
|
||||||
},
|
},
|
||||||
@ -136,6 +138,8 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
try:
|
try:
|
||||||
controller = TeslaAPI(
|
controller = TeslaAPI(
|
||||||
websession,
|
websession,
|
||||||
|
email=config.get(CONF_USERNAME),
|
||||||
|
password=config.get(CONF_PASSWORD),
|
||||||
refresh_token=config[CONF_TOKEN],
|
refresh_token=config[CONF_TOKEN],
|
||||||
access_token=config[CONF_ACCESS_TOKEN],
|
access_token=config[CONF_ACCESS_TOKEN],
|
||||||
update_interval=config_entry.options.get(
|
update_interval=config_entry.options.get(
|
||||||
|
@ -140,6 +140,8 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
(config[CONF_TOKEN], config[CONF_ACCESS_TOKEN]) = await controller.connect(
|
(config[CONF_TOKEN], config[CONF_ACCESS_TOKEN]) = await controller.connect(
|
||||||
test_login=True
|
test_login=True
|
||||||
)
|
)
|
||||||
|
config[CONF_USERNAME] = data[CONF_USERNAME]
|
||||||
|
config[CONF_PASSWORD] = data[CONF_PASSWORD]
|
||||||
except TeslaException as ex:
|
except TeslaException as ex:
|
||||||
if ex.code == HTTP_UNAUTHORIZED:
|
if ex.code == HTTP_UNAUTHORIZED:
|
||||||
_LOGGER.error("Invalid credentials: %s", ex)
|
_LOGGER.error("Invalid credentials: %s", ex)
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
"name": "Tesla",
|
"name": "Tesla",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
||||||
"requirements": ["teslajsonpy==0.10.4"],
|
"requirements": ["teslajsonpy==0.11.5"],
|
||||||
"codeowners": ["@zabuldon", "@alandtse"],
|
"codeowners": ["@zabuldon", "@alandtse"],
|
||||||
"dhcp": [
|
"dhcp": [
|
||||||
{"hostname":"tesla_*","macaddress":"4CFCAA*"},
|
{ "hostname": "tesla_*", "macaddress": "4CFCAA*" },
|
||||||
{"hostname":"tesla_*","macaddress":"044EAF*"},
|
{ "hostname": "tesla_*", "macaddress": "044EAF*" },
|
||||||
{"hostname":"tesla_*","macaddress":"98ED5C*"}
|
{ "hostname": "tesla_*", "macaddress": "98ED5C*" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2184,7 +2184,7 @@ temperusb==1.5.3
|
|||||||
tesla-powerwall==0.3.3
|
tesla-powerwall==0.3.3
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.10.4
|
teslajsonpy==0.11.5
|
||||||
|
|
||||||
# homeassistant.components.tensorflow
|
# homeassistant.components.tensorflow
|
||||||
# tf-models-official==2.3.0
|
# tf-models-official==2.3.0
|
||||||
|
@ -1105,7 +1105,7 @@ tellduslive==0.10.11
|
|||||||
tesla-powerwall==0.3.3
|
tesla-powerwall==0.3.3
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.10.4
|
teslajsonpy==0.11.5
|
||||||
|
|
||||||
# homeassistant.components.toon
|
# homeassistant.components.toon
|
||||||
toonapi==0.2.0
|
toonapi==0.2.0
|
||||||
|
@ -48,6 +48,8 @@ async def test_form(hass):
|
|||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result2["title"] == "test@email.com"
|
assert result2["title"] == "test@email.com"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
|
CONF_USERNAME: "test@email.com",
|
||||||
|
CONF_PASSWORD: "test",
|
||||||
CONF_TOKEN: "test-refresh-token",
|
CONF_TOKEN: "test-refresh-token",
|
||||||
CONF_ACCESS_TOKEN: "test-access-token",
|
CONF_ACCESS_TOKEN: "test-access-token",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user