mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Log bare exceptions in the config flow (#135584)
* Log bare exceptions in the config flow * add more * Fix
This commit is contained in:
parent
348ebe1402
commit
615afeb4d5
@ -102,7 +102,8 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
device = await self._get_device_data(discovery_info)
|
device = await self._get_device_data(discovery_info)
|
||||||
except AirthingsDeviceUpdateError:
|
except AirthingsDeviceUpdateError:
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unknown error occurred")
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
|
|
||||||
name = get_name(device)
|
name = get_name(device)
|
||||||
@ -160,7 +161,8 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
device = await self._get_device_data(discovery_info)
|
device = await self._get_device_data(discovery_info)
|
||||||
except AirthingsDeviceUpdateError:
|
except AirthingsDeviceUpdateError:
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unknown error occurred")
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
name = get_name(device)
|
name = get_name(device)
|
||||||
self._discovered_devices[address] = Discovery(name, discovery_info, device)
|
self._discovered_devices[address] = Discovery(name, discovery_info, device)
|
||||||
|
@ -32,7 +32,8 @@ class AirTouch5ConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
client = Airtouch5SimpleClient(user_input[CONF_HOST])
|
client = Airtouch5SimpleClient(user_input[CONF_HOST])
|
||||||
try:
|
try:
|
||||||
await client.test_connection()
|
await client.test_connection()
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors = {"base": "cannot_connect"}
|
errors = {"base": "cannot_connect"}
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(user_input[CONF_HOST])
|
await self.async_set_unique_id(user_input[CONF_HOST])
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from anova_wifi import AnovaApi, InvalidLogin
|
from anova_wifi import AnovaApi, InvalidLogin
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -11,8 +13,10 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class AnovaConfligFlow(ConfigFlow, domain=DOMAIN):
|
|
||||||
|
class AnovaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Sets up a config flow for Anova."""
|
"""Sets up a config flow for Anova."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
@ -35,7 +39,8 @@ class AnovaConfligFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
await api.authenticate()
|
await api.authenticate()
|
||||||
except InvalidLogin:
|
except InvalidLogin:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -60,7 +60,7 @@ class AquaCellConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except AuthenticationFailed:
|
except AuthenticationFailed:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -44,7 +44,7 @@ class ChaconDioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except DIOChaconInvalidAuthError:
|
except DIOChaconInvalidAuthError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -21,6 +22,8 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
|
class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Deluge."""
|
"""Handle a config flow for Deluge."""
|
||||||
@ -86,7 +89,8 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
await self.hass.async_add_executor_job(api.connect)
|
await self.hass.async_add_executor_job(api.connect)
|
||||||
except (ConnectionRefusedError, TimeoutError, SSLError):
|
except (ConnectionRefusedError, TimeoutError, SSLError):
|
||||||
return "cannot_connect"
|
return "cannot_connect"
|
||||||
except Exception as ex: # noqa: BLE001
|
except Exception as ex:
|
||||||
|
_LOGGER.exception("Unexpected error")
|
||||||
if type(ex).__name__ == "BadLoginError":
|
if type(ex).__name__ == "BadLoginError":
|
||||||
return "invalid_auth"
|
return "invalid_auth"
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pydexcom import AccountError, Dexcom, SessionError
|
from pydexcom import AccountError, Dexcom, SessionError
|
||||||
@ -12,6 +13,8 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
|||||||
|
|
||||||
from .const import CONF_SERVER, DOMAIN, SERVER_OUS, SERVER_US
|
from .const import CONF_SERVER, DOMAIN, SERVER_OUS, SERVER_US
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_USERNAME): str,
|
vol.Required(CONF_USERNAME): str,
|
||||||
@ -43,7 +46,8 @@ class DexcomConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except AccountError:
|
except AccountError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected error")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
|
||||||
if "base" not in errors:
|
if "base" not in errors:
|
||||||
|
@ -62,6 +62,7 @@ class EheimDigitalConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except (ClientError, TimeoutError):
|
except (ClientError, TimeoutError):
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
|
LOGGER.exception("Unknown exception occurred")
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
await self.async_set_unique_id(hub.main.mac_address)
|
await self.async_set_unique_id(hub.main.mac_address)
|
||||||
self._abort_if_unique_id_configured(updates={CONF_HOST: host})
|
self._abort_if_unique_id_configured(updates={CONF_HOST: host})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Config flow for Enigma2."""
|
"""Config flow for Enigma2."""
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientError
|
from aiohttp.client_exceptions import ClientError
|
||||||
@ -63,6 +64,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def get_options_schema(handler: SchemaCommonFlowHandler) -> vol.Schema:
|
async def get_options_schema(handler: SchemaCommonFlowHandler) -> vol.Schema:
|
||||||
"""Get the options schema."""
|
"""Get the options schema."""
|
||||||
@ -130,7 +133,8 @@ class Enigma2ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors = {"base": "invalid_auth"}
|
errors = {"base": "invalid_auth"}
|
||||||
except ClientError:
|
except ClientError:
|
||||||
errors = {"base": "cannot_connect"}
|
errors = {"base": "cannot_connect"}
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors = {"base": "unknown"}
|
errors = {"base": "unknown"}
|
||||||
else:
|
else:
|
||||||
unique_id = about["info"]["ifaces"][0]["mac"] or self.unique_id
|
unique_id = about["info"]["ifaces"][0]["mac"] or self.unique_id
|
||||||
|
@ -149,7 +149,7 @@ class FroniusConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
unique_id, info = await validate_host(self.hass, user_input[CONF_HOST])
|
unique_id, info = await validate_host(self.hass, user_input[CONF_HOST])
|
||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -108,8 +108,8 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._webfsapi_url = await AFSAPI.get_webfsapi_endpoint(device_url)
|
self._webfsapi_url = await AFSAPI.get_webfsapi_endpoint(device_url)
|
||||||
except FSConnectionError:
|
except FSConnectionError:
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
except Exception as exception: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.debug(exception)
|
_LOGGER.exception("Unexpected exception")
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
|
|
||||||
# try to login with default pin
|
# try to login with default pin
|
||||||
|
@ -62,7 +62,7 @@ class FGLairConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except AylaAuthError:
|
except AylaAuthError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ class FytaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return {"base": "invalid_auth"}
|
return {"base": "invalid_auth"}
|
||||||
except FytaPasswordError:
|
except FytaPasswordError:
|
||||||
return {"base": "invalid_auth", CONF_PASSWORD: "password_error"}
|
return {"base": "invalid_auth", CONF_PASSWORD: "password_error"}
|
||||||
except Exception as e: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.error(e)
|
_LOGGER.exception("Unexpected exception")
|
||||||
return {"base": "unknown"}
|
return {"base": "unknown"}
|
||||||
finally:
|
finally:
|
||||||
await fyta.client.close()
|
await fyta.client.close()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Any, Self
|
from typing import Any, Self
|
||||||
|
|
||||||
@ -27,6 +28,8 @@ from homeassistant.helpers.service_info.zeroconf import (
|
|||||||
from .common import get_api
|
from .common import get_api
|
||||||
from .const import DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, DOMAIN
|
from .const import DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEVICE_NAMES = {
|
DEVICE_NAMES = {
|
||||||
DEVICE_TYPE_GOGOGATE2: "Gogogate2",
|
DEVICE_TYPE_GOGOGATE2: "Gogogate2",
|
||||||
DEVICE_TYPE_ISMARTGATE: "ismartgate",
|
DEVICE_TYPE_ISMARTGATE: "ismartgate",
|
||||||
@ -115,7 +118,8 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
else:
|
else:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
if self._ip_address and self._device_type:
|
if self._ip_address and self._device_type:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from asyncio import timeout
|
from asyncio import timeout
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from hko import HKO, LOCATIONS, HKOError
|
from hko import HKO, LOCATIONS, HKOError
|
||||||
@ -15,6 +16,8 @@ from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
|||||||
|
|
||||||
from .const import API_RHRREAD, DEFAULT_LOCATION, DOMAIN, KEY_LOCATION
|
from .const import API_RHRREAD, DEFAULT_LOCATION, DOMAIN, KEY_LOCATION
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_loc_name(item):
|
def get_loc_name(item):
|
||||||
"""Return an array of supported locations."""
|
"""Return an array of supported locations."""
|
||||||
@ -54,7 +57,8 @@ class HKOConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
except HKOError:
|
except HKOError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
|
@ -52,7 +52,7 @@ class HomeeConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except HomeeAuthenticationFailedException:
|
except HomeeAuthenticationFailedException:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -178,8 +178,8 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
except Timeout:
|
except Timeout:
|
||||||
_LOGGER.warning("Connection timeout", exc_info=True)
|
_LOGGER.warning("Connection timeout", exc_info=True)
|
||||||
errors[CONF_URL] = "connection_timeout"
|
errors[CONF_URL] = "connection_timeout"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.warning("Unknown error connecting to device", exc_info=True)
|
_LOGGER.exception("Unknown error connecting to device")
|
||||||
errors[CONF_URL] = "unknown"
|
errors[CONF_URL] = "unknown"
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
conn.close()
|
conn.close()
|
||||||
conn.requests_session.close()
|
conn.requests_session.close()
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.debug("Disconnect error", exc_info=True)
|
_LOGGER.exception("Disconnect error")
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
@ -54,7 +54,8 @@ class HusqvarnaConfigFlowHandler(
|
|||||||
automower_api = AutomowerSession(AsyncConfigFlowAuth(websession, token), tz)
|
automower_api = AutomowerSession(AsyncConfigFlowAuth(websession, token), tz)
|
||||||
try:
|
try:
|
||||||
status_data = await automower_api.get_status()
|
status_data = await automower_api.get_status()
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
if status_data == {}:
|
if status_data == {}:
|
||||||
return self.async_abort(reason="no_mower_connected")
|
return self.async_abort(reason="no_mower_connected")
|
||||||
|
@ -50,7 +50,7 @@ class ImgwPibFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
hydrological_data = await imgwpib.get_hydrological_data()
|
hydrological_data = await imgwpib.get_hydrological_data()
|
||||||
except (ClientError, TimeoutError, ApiError):
|
except (ClientError, TimeoutError, ApiError):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from incomfortclient import InvalidGateway, InvalidHeaterList
|
from incomfortclient import InvalidGateway, InvalidHeaterList
|
||||||
@ -31,6 +32,7 @@ from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
|||||||
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
from .const import CONF_LEGACY_SETPOINT_STATUS, DOMAIN
|
||||||
from .coordinator import InComfortConfigEntry, async_connect_gateway
|
from .coordinator import InComfortConfigEntry, async_connect_gateway
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
TITLE = "Intergas InComfort/Intouch Lan2RF gateway"
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
@ -88,7 +90,8 @@ async def async_try_connect_gateway(
|
|||||||
return {"base": "no_heaters"}
|
return {"base": "no_heaters"}
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
return {"base": "timeout_error"}
|
return {"base": "timeout_error"}
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
return {"base": "unknown"}
|
return {"base": "unknown"}
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pylast import LastFMNetwork, PyLastError, User, WSError
|
from pylast import LastFMNetwork, PyLastError, User, WSError
|
||||||
@ -32,6 +33,8 @@ CONFIG_SCHEMA: vol.Schema = vol.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_lastfm_user(api_key: str, username: str) -> tuple[User, dict[str, str]]:
|
def get_lastfm_user(api_key: str, username: str) -> tuple[User, dict[str, str]]:
|
||||||
"""Get and validate lastFM User."""
|
"""Get and validate lastFM User."""
|
||||||
@ -49,7 +52,8 @@ def get_lastfm_user(api_key: str, username: str) -> tuple[User, dict[str, str]]:
|
|||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
else:
|
else:
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
return user, errors
|
return user, errors
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from meater import AuthenticationError, MeaterApi, ServiceUnavailableError
|
from meater import AuthenticationError, MeaterApi, ServiceUnavailableError
|
||||||
@ -14,6 +15,8 @@ from homeassistant.helpers import aiohttp_client
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REAUTH_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
REAUTH_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||||
USER_SCHEMA = vol.Schema(
|
USER_SCHEMA = vol.Schema(
|
||||||
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
|
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
|
||||||
@ -84,7 +87,8 @@ class MeaterConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except ServiceUnavailableError:
|
except ServiceUnavailableError:
|
||||||
errors["base"] = "service_unavailable_error"
|
errors["base"] = "service_unavailable_error"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown_auth_error"
|
errors["base"] = "unknown_auth_error"
|
||||||
else:
|
else:
|
||||||
data = {"username": username, "password": password}
|
data = {"username": username, "password": password}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from motionblinds import MotionDiscovery, MotionGateway
|
from motionblinds import MotionDiscovery, MotionGateway
|
||||||
@ -28,6 +29,8 @@ from .const import (
|
|||||||
)
|
)
|
||||||
from .gateway import ConnectMotionGateway
|
from .gateway import ConnectMotionGateway
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(CONF_HOST): str,
|
vol.Optional(CONF_HOST): str,
|
||||||
@ -93,7 +96,8 @@ class MotionBlindsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
# key not needed for GetDeviceList request
|
# key not needed for GetDeviceList request
|
||||||
await self.hass.async_add_executor_job(gateway.GetDeviceList)
|
await self.hass.async_add_executor_job(gateway.GetDeviceList)
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Failed to connect to Motion Gateway")
|
||||||
return self.async_abort(reason="not_motionblinds")
|
return self.async_abort(reason="not_motionblinds")
|
||||||
|
|
||||||
if not gateway.available:
|
if not gateway.available:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Config flow for Mullvad VPN integration."""
|
"""Config flow for Mullvad VPN integration."""
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from mullvad_api import MullvadAPI, MullvadAPIError
|
from mullvad_api import MullvadAPI, MullvadAPIError
|
||||||
@ -8,6 +9,8 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MullvadConfigFlow(ConfigFlow, domain=DOMAIN):
|
class MullvadConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Mullvad VPN."""
|
"""Handle a config flow for Mullvad VPN."""
|
||||||
@ -24,7 +27,8 @@ class MullvadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
await self.hass.async_add_executor_job(MullvadAPI)
|
await self.hass.async_add_executor_job(MullvadAPI)
|
||||||
except MullvadAPIError:
|
except MullvadAPIError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(title="Mullvad VPN", data=user_input)
|
return self.async_create_entry(title="Mullvad VPN", data=user_input)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -16,6 +17,8 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required("host"): str})
|
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required("host"): str})
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +63,8 @@ class MuteSyncConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -103,7 +103,7 @@ class NASwebConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "missing_status"
|
errors["base"] = "missing_status"
|
||||||
except AbortFlow:
|
except AbortFlow:
|
||||||
raise
|
raise
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
@ -19,6 +20,8 @@ from .const import CONF_PROFILE_ID, DOMAIN
|
|||||||
|
|
||||||
AUTH_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): str})
|
AUTH_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): str})
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_init_nextdns(hass: HomeAssistant, api_key: str) -> NextDns:
|
async def async_init_nextdns(hass: HomeAssistant, api_key: str) -> NextDns:
|
||||||
"""Check if credentials are valid."""
|
"""Check if credentials are valid."""
|
||||||
@ -51,7 +54,8 @@ class NextDnsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_api_key"
|
errors["base"] = "invalid_api_key"
|
||||||
except (ApiError, ClientConnectorError, RetryError, TimeoutError):
|
except (ApiError, ClientConnectorError, RetryError, TimeoutError):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return await self.async_step_profiles()
|
return await self.async_step_profiles()
|
||||||
@ -111,7 +115,8 @@ class NextDnsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_api_key"
|
errors["base"] = "invalid_api_key"
|
||||||
except (ApiError, ClientConnectorError, RetryError, TimeoutError):
|
except (ApiError, ClientConnectorError, RetryError, TimeoutError):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from nhc.controller import NHCController
|
from nhc.controller import NHCController
|
||||||
@ -12,6 +13,8 @@ from homeassistant.const import CONF_HOST
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST): str,
|
vol.Required(CONF_HOST): str,
|
||||||
@ -25,7 +28,8 @@ async def test_connection(host: str) -> str | None:
|
|||||||
controller = NHCController(host, 8000)
|
controller = NHCController(host, 8000)
|
||||||
try:
|
try:
|
||||||
await controller.connect()
|
await controller.connect()
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
return "cannot_connect"
|
return "cannot_connect"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -85,7 +85,8 @@ class OctoPrintConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
raise err from None
|
raise err from None
|
||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Config flow for ProgettiHWSW Automation integration."""
|
"""Config flow for ProgettiHWSW Automation integration."""
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI
|
from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI
|
||||||
@ -11,6 +12,8 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{vol.Required("host"): str, vol.Required("port", default=80): int}
|
{vol.Required("host"): str, vol.Required("port", default=80): int}
|
||||||
)
|
)
|
||||||
@ -86,7 +89,8 @@ class ProgettiHWSWConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
info = await validate_input(self.hass, user_input)
|
info = await validate_input(self.hass, user_input)
|
||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
user_input.update(info)
|
user_input.update(info)
|
||||||
|
@ -70,8 +70,8 @@ class QnapConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except TypeError:
|
except TypeError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception as error: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.error(error)
|
_LOGGER.exception("Unexpected error")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
unique_id = stats["system"]["serial_number"]
|
unique_id = stats["system"]["serial_number"]
|
||||||
|
@ -74,8 +74,8 @@ class RabbitAirConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_host"
|
errors["base"] = "invalid_host"
|
||||||
except TimeoutConnect:
|
except TimeoutConnect:
|
||||||
errors["base"] = "timeout_connect"
|
errors["base"] = "timeout_connect"
|
||||||
except Exception as err: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.debug("Unexpected exception: %s", err)
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
user_input[CONF_MAC] = info["mac"]
|
user_input[CONF_MAC] = info["mac"]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -16,6 +17,8 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
|||||||
from .const import CONF_KAMEREON_ACCOUNT_ID, CONF_LOCALE, DOMAIN
|
from .const import CONF_KAMEREON_ACCOUNT_ID, CONF_LOCALE, DOMAIN
|
||||||
from .renault_hub import RenaultHub
|
from .renault_hub import RenaultHub
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
USER_SCHEMA = vol.Schema(
|
USER_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_LOCALE): vol.In(AVAILABLE_LOCALES.keys()),
|
vol.Required(CONF_LOCALE): vol.In(AVAILABLE_LOCALES.keys()),
|
||||||
@ -54,7 +57,8 @@ class RenaultFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
except (aiohttp.ClientConnectionError, GigyaException):
|
except (aiohttp.ClientConnectionError, GigyaException):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
if login_success:
|
if login_success:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aioskybell import Skybell, exceptions
|
from aioskybell import Skybell, exceptions
|
||||||
@ -14,6 +15,8 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SkybellFlowHandler(ConfigFlow, domain=DOMAIN):
|
class SkybellFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Skybell."""
|
"""Handle a config flow for Skybell."""
|
||||||
@ -95,6 +98,7 @@ class SkybellFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return None, "invalid_auth"
|
return None, "invalid_auth"
|
||||||
except exceptions.SkybellException:
|
except exceptions.SkybellException:
|
||||||
return None, "cannot_connect"
|
return None, "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
return None, "unknown"
|
return None, "unknown"
|
||||||
return skybell.user_id, None
|
return skybell.user_id, None
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Config flow for Smarty integration."""
|
"""Config flow for Smarty integration."""
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pysmarty2 import Smarty
|
from pysmarty2 import Smarty
|
||||||
@ -10,6 +11,8 @@ from homeassistant.const import CONF_HOST, CONF_NAME
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SmartyConfigFlow(ConfigFlow, domain=DOMAIN):
|
class SmartyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Smarty config flow."""
|
"""Smarty config flow."""
|
||||||
@ -20,7 +23,8 @@ class SmartyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
if smarty.update():
|
if smarty.update():
|
||||||
return None
|
return None
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
return "unknown"
|
return "unknown"
|
||||||
else:
|
else:
|
||||||
return "cannot_connect"
|
return "cannot_connect"
|
||||||
|
@ -41,7 +41,8 @@ class SpotifyFlowHandler(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
current_user = await spotify.get_current_user()
|
current_user = await spotify.get_current_user()
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
self.logger.exception("Error while connecting to Spotify")
|
||||||
return self.async_abort(reason="connection_error")
|
return self.async_abort(reason="connection_error")
|
||||||
|
|
||||||
name = current_user.display_name
|
name = current_user.display_name
|
||||||
|
@ -151,7 +151,8 @@ class SqueezeboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
if server.http_status == HTTPStatus.UNAUTHORIZED:
|
if server.http_status == HTTPStatus.UNAUTHORIZED:
|
||||||
return "invalid_auth"
|
return "invalid_auth"
|
||||||
return "cannot_connect"
|
return "cannot_connect"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unknown exception while validating connection")
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
if "uuid" in status:
|
if "uuid" in status:
|
||||||
|
@ -190,7 +190,7 @@ class SwissPublicTransportConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return "cannot_connect"
|
return "cannot_connect"
|
||||||
except OpendataTransportError:
|
except OpendataTransportError:
|
||||||
return "bad_config"
|
return "bad_config"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unknown error")
|
_LOGGER.exception("Unknown error")
|
||||||
return "unknown"
|
return "unknown"
|
||||||
return None
|
return None
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pytrafikverket import TrafikverketFerry
|
from pytrafikverket import TrafikverketFerry
|
||||||
@ -17,6 +18,8 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||||||
from .const import CONF_FROM, CONF_TIME, CONF_TO, DOMAIN
|
from .const import CONF_FROM, CONF_TIME, CONF_TO, DOMAIN
|
||||||
from .util import create_unique_id
|
from .util import create_unique_id
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_API_KEY): selector.TextSelector(
|
vol.Required(CONF_API_KEY): selector.TextSelector(
|
||||||
@ -81,7 +84,8 @@ class TVFerryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except NoFerryFound:
|
except NoFerryFound:
|
||||||
errors["base"] = "invalid_route"
|
errors["base"] = "invalid_route"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
@ -120,7 +124,8 @@ class TVFerryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except NoFerryFound:
|
except NoFerryFound:
|
||||||
errors["base"] = "invalid_route"
|
errors["base"] = "invalid_route"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
if not errors:
|
if not errors:
|
||||||
|
@ -86,8 +86,8 @@ async def validate_station(
|
|||||||
except UnknownError as error:
|
except UnknownError as error:
|
||||||
_LOGGER.error("Unknown error occurred during validation %s", str(error))
|
_LOGGER.error("Unknown error occurred during validation %s", str(error))
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception as error: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.error("Unknown exception occurred during validation %s", str(error))
|
_LOGGER.exception("Unknown exception occurred during validation")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
return (stations, errors)
|
return (stations, errors)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pytrafikverket.exceptions import (
|
from pytrafikverket.exceptions import (
|
||||||
@ -25,6 +26,8 @@ from homeassistant.helpers.selector import (
|
|||||||
|
|
||||||
from .const import CONF_STATION, DOMAIN
|
from .const import CONF_STATION, DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TVWeatherConfigFlow(ConfigFlow, domain=DOMAIN):
|
class TVWeatherConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Trafikverket Weatherstation integration."""
|
"""Handle a config flow for Trafikverket Weatherstation integration."""
|
||||||
@ -56,7 +59,8 @@ class TVWeatherConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_station"
|
errors["base"] = "invalid_station"
|
||||||
except MultipleWeatherStationsFound:
|
except MultipleWeatherStationsFound:
|
||||||
errors["base"] = "more_stations"
|
errors["base"] = "more_stations"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected error")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
@ -102,7 +106,8 @@ class TVWeatherConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_station"
|
errors["base"] = "invalid_station"
|
||||||
except MultipleWeatherStationsFound:
|
except MultipleWeatherStationsFound:
|
||||||
errors["base"] = "more_stations"
|
errors["base"] = "more_stations"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
@ -132,7 +137,8 @@ class TVWeatherConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_station"
|
errors["base"] = "invalid_station"
|
||||||
except MultipleWeatherStationsFound:
|
except MultipleWeatherStationsFound:
|
||||||
errors["base"] = "more_stations"
|
errors["base"] = "more_stations"
|
||||||
except Exception: # noqa: BLE001
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
|
@ -57,7 +57,7 @@ class TriggerCMDConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors[CONF_TOKEN] = "invalid_token"
|
errors[CONF_TOKEN] = "invalid_token"
|
||||||
except TRIGGERcmdConnectionError:
|
except TRIGGERcmdConnectionError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -108,7 +108,7 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors[CONF_HOST] = "invalid_host"
|
errors[CONF_HOST] = "invalid_host"
|
||||||
except ValloxApiException:
|
except ValloxApiException:
|
||||||
errors[CONF_HOST] = "cannot_connect"
|
errors[CONF_HOST] = "cannot_connect"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors[CONF_HOST] = "unknown"
|
errors[CONF_HOST] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
@ -114,8 +114,8 @@ class DomainConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except Exception as err: # noqa: BLE001
|
except Exception:
|
||||||
_LOGGER.error("Unexpected exception: %s", err)
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(info[CONF_ID])
|
await self.async_set_unique_id(info[CONF_ID])
|
||||||
|
@ -67,7 +67,7 @@ class WebDavConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except MethodNotSupportedError:
|
except MethodNotSupportedError:
|
||||||
errors["base"] = "invalid_method"
|
errors["base"] = "invalid_method"
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected error")
|
_LOGGER.exception("Unexpected error")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user