Skip to content

Commit f838e85

Browse files
chemelli74frenck
andcommitted
Manager wrong country selection in Alexa Devices (home-assistant#147914)
Co-authored-by: Franck Nijhof <[email protected]>
1 parent 04ae966 commit f838e85

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

homeassistant/components/alexa_devices/config_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any
66

77
from aioamazondevices.api import AmazonEchoApi
8-
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
8+
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
99
import voluptuous as vol
1010

1111
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
@@ -36,6 +36,8 @@ async def async_step_user(
3636
errors["base"] = "cannot_connect"
3737
except CannotAuthenticate:
3838
errors["base"] = "invalid_auth"
39+
except WrongCountry:
40+
errors["base"] = "wrong_country"
3941
else:
4042
await self.async_set_unique_id(data["customer_info"]["user_id"])
4143
self._abort_if_unique_id_configured()

homeassistant/components/alexa_devices/strings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"error": {
3434
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
3535
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
36+
"wrong_country": "Wrong country selected. Please select the country where your Amazon account is registered.",
3637
"unknown": "[%key:common::config_flow::error::unknown%]"
3738
}
3839
},

tests/components/alexa_devices/test_config_flow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from unittest.mock import AsyncMock
44

5-
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect
5+
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
66
import pytest
77

88
from homeassistant.components.alexa_devices.const import CONF_LOGIN_DATA, DOMAIN
@@ -57,6 +57,7 @@ async def test_full_flow(
5757
[
5858
(CannotConnect, "cannot_connect"),
5959
(CannotAuthenticate, "invalid_auth"),
60+
(WrongCountry, "wrong_country"),
6061
],
6162
)
6263
async def test_flow_errors(

0 commit comments

Comments
 (0)