Corrected spelling fixed typing reordered imports

###Fix
# In preparation for pull request to homeassistant core, just corrected some spelling, sorted imports using isort and corrected some type hinting
This commit is contained in:
RyanClark123
2023-05-26 16:29:40 +01:00
parent 5328933de3
commit c6f37493ca
5 changed files with 75 additions and 62 deletions
+25 -14
View File
@@ -4,26 +4,32 @@ from __future__ import annotations
import logging
from pyowletapi.api import OwletAPI
from pyowletapi.exceptions import (
OwletAuthenticationError,
OwletConnectionError,
OwletDevicesError,
OwletEmailError,
OwletPasswordError,
)
from pyowletapi.sock import Sock
from pyowletapi.exceptions import OwletAuthenticationError
from homeassistant.config_entries import ConfigEntry, ConfigEntryAuthFailed
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryAuthFailed,
ConfigEntryNotReady,
)
from homeassistant.const import (
Platform,
CONF_REGION,
CONF_USERNAME,
CONF_PASSWORD,
CONF_SCAN_INTERVAL,
CONF_API_TOKEN,
CONF_REGION,
CONF_SCAN_INTERVAL,
CONF_USERNAME,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import (
DOMAIN,
CONF_OWLET_EXPIRY,
CONF_OWLET_REFRESH,
SUPPORTED_VERSIONS,
)
from homeassistant.helpers.device_registry import DeviceEntry
from .const import CONF_OWLET_EXPIRY, CONF_OWLET_REFRESH, DOMAIN, SUPPORTED_VERSIONS
from .coordinator import OwletCoordinator
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
@@ -61,12 +67,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
for device in devices["response"]
}
except OwletAuthenticationError as err:
except (OwletAuthenticationError, OwletEmailError, OwletPasswordError) as err:
_LOGGER.error("Credentials no longer valid, please setup owlet again")
raise ConfigEntryAuthFailed(
f"Credentials expired for {entry.data[CONF_USERNAME]}"
) from err
except OwletConnectionError as err:
raise ConfigEntryNotReady(
f"Error connecting to {entry.data[CONF_USERNAME]}"
) from err
coordinators = [
OwletCoordinator(hass, sock, entry.options.get(CONF_SCAN_INTERVAL))
for sock in socks.values()