Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion homeassistant/components/alexa_devices/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
from typing import Any

from aioamazondevices.api import AmazonEchoApi
from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
from aioamazondevices.exceptions import (
CannotAuthenticate,
CannotConnect,
CannotRetrieveData,
WrongCountry,
)
import voluptuous as vol

from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
Expand Down Expand Up @@ -57,6 +62,8 @@ async def async_step_user(
errors["base"] = "cannot_connect"
except CannotAuthenticate:
errors["base"] = "invalid_auth"
except CannotRetrieveData:
errors["base"] = "cannot_retrieve_data"
except WrongCountry:
errors["base"] = "wrong_country"
else:
Expand Down Expand Up @@ -106,6 +113,8 @@ async def async_step_reauth_confirm(
errors["base"] = "cannot_connect"
except CannotAuthenticate:
errors["base"] = "invalid_auth"
except CannotRetrieveData:
errors["base"] = "cannot_retrieve_data"
else:
return self.async_update_reload_and_abort(
reauth_entry,
Expand Down
14 changes: 12 additions & 2 deletions homeassistant/components/alexa_devices/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ async def _async_update_data(self) -> dict[str, AmazonDevice]:
try:
await self.api.login_mode_stored_data()
return await self.api.get_devices_data()
except (CannotConnect, CannotRetrieveData) as err:
raise UpdateFailed(f"Error occurred while updating {self.name}") from err
except CannotConnect as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="cannot_connect_with_error",
translation_placeholders={"error": repr(err)},
) from err
except CannotRetrieveData as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="cannot_retrieve_data_with_error",
translation_placeholders={"error": repr(err)},
) from err
except CannotAuthenticate as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/alexa_devices/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"integration_type": "hub",
"iot_class": "cloud_polling",
"loggers": ["aioamazondevices"],
"quality_scale": "bronze",
"quality_scale": "silver",
"requirements": ["aioamazondevices==3.2.8"]
}
5 changes: 3 additions & 2 deletions homeassistant/components/alexa_devices/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"cannot_retrieve_data": "Unable to retrieve data from Amazon. Please try again later.",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"wrong_country": "Wrong country selected. Please select the country where your Amazon account is registered.",
"unknown": "[%key:common::config_flow::error::unknown%]"
Expand Down Expand Up @@ -84,10 +85,10 @@
}
},
"exceptions": {
"cannot_connect": {
"cannot_connect_with_error": {
"message": "Error connecting: {error}"
},
"cannot_retrieve_data": {
"cannot_retrieve_data_with_error": {
"message": "Error retrieving data: {error}"
}
}
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/alexa_devices/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ async def cmd_wrapper(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> None:
self.coordinator.last_update_success = False
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="cannot_connect",
translation_key="cannot_connect_with_error",
translation_placeholders={"error": repr(err)},
) from err
except CannotRetrieveData as err:
self.coordinator.last_update_success = False
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="cannot_retrieve_data",
translation_key="cannot_retrieve_data_with_error",
translation_placeholders={"error": repr(err)},
) from err

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/iskra/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@
"name": "Phase 3 current"
},
"non_resettable_counter_1": {
"name": "Non Resettable counter 1"
"name": "Non-resettable counter 1"
},
"non_resettable_counter_2": {
"name": "Non Resettable counter 2"
"name": "Non-resettable counter 2"
},
"non_resettable_counter_3": {
"name": "Non Resettable counter 3"
"name": "Non-resettable counter 3"
},
"non_resettable_counter_4": {
"name": "Non Resettable counter 4"
"name": "Non-resettable counter 4"
},
"resettable_counter_1": {
"name": "Resettable counter 1"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"config_entry_not_loaded": "The Z-Wave configuration entry is not loaded. Please try again when the configuration entry is loaded.",
"different_device": "The connected USB device is not the same as previously configured for this config entry. Please instead create a new config entry for the new device.",
"discovery_requires_supervisor": "Discovery requires the supervisor.",
"migration_low_sdk_version": "The SDK version of the old adapter is lower than {ok_sdk_version}. This means it's not possible to migrate the Non Volatile Memory (NVM) of the old adapter to another adapter.\n\nCheck the documentation on the manufacturer support pages of the old adapter, if it's possible to upgrade the firmware of the old adapter to a version that is built with SDK version {ok_sdk_version} or higher.",
"migration_low_sdk_version": "The SDK version of the old adapter is lower than {ok_sdk_version}. This means it's not possible to migrate the non-volatile memory (NVM) of the old adapter to another adapter.\n\nCheck the documentation on the manufacturer support pages of the old adapter, if it's possible to upgrade the firmware of the old adapter to a version that is built with SDK version {ok_sdk_version} or higher.",
"migration_successful": "Migration successful.",
"not_zwave_device": "Discovered device is not a Z-Wave device.",
"not_zwave_js_addon": "Discovered add-on is not the official Z-Wave add-on.",
Expand Down
9 changes: 8 additions & 1 deletion tests/components/alexa_devices/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from unittest.mock import AsyncMock

from aioamazondevices.exceptions import CannotAuthenticate, CannotConnect, WrongCountry
from aioamazondevices.exceptions import (
CannotAuthenticate,
CannotConnect,
CannotRetrieveData,
WrongCountry,
)
import pytest

from homeassistant.components.alexa_devices.const import CONF_LOGIN_DATA, DOMAIN
Expand Down Expand Up @@ -57,6 +62,7 @@ async def test_full_flow(
[
(CannotConnect, "cannot_connect"),
(CannotAuthenticate, "invalid_auth"),
(CannotRetrieveData, "cannot_retrieve_data"),
(WrongCountry, "wrong_country"),
],
)
Expand Down Expand Up @@ -165,6 +171,7 @@ async def test_reauth_successful(
[
(CannotConnect, "cannot_connect"),
(CannotAuthenticate, "invalid_auth"),
(CannotRetrieveData, "cannot_retrieve_data"),
],
)
async def test_reauth_not_successful(
Expand Down
4 changes: 2 additions & 2 deletions tests/components/alexa_devices/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
@pytest.mark.parametrize(
("side_effect", "key", "error"),
[
(CannotConnect, "cannot_connect", "CannotConnect()"),
(CannotRetrieveData, "cannot_retrieve_data", "CannotRetrieveData()"),
(CannotConnect, "cannot_connect_with_error", "CannotConnect()"),
(CannotRetrieveData, "cannot_retrieve_data_with_error", "CannotRetrieveData()"),
],
)
async def test_alexa_api_call_exceptions(
Expand Down
Loading