diff --git a/homeassistant/components/sharkiq/__init__.py b/homeassistant/components/sharkiq/__init__.py index 08235a57780..172ad6722ea 100644 --- a/homeassistant/components/sharkiq/__init__.py +++ b/homeassistant/components/sharkiq/__init__.py @@ -17,7 +17,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession -from .const import _LOGGER, API_TIMEOUT, DOMAIN, PLATFORMS +from .const import API_TIMEOUT, DOMAIN, LOGGER, PLATFORMS from .update_coordinator import SharkIqUpdateCoordinator @@ -29,13 +29,13 @@ async def async_connect_or_timeout(ayla_api: AylaApi) -> bool: """Connect to vacuum.""" try: async with async_timeout.timeout(API_TIMEOUT): - _LOGGER.debug("Initialize connection to Ayla networks API") + LOGGER.debug("Initialize connection to Ayla networks API") await ayla_api.async_sign_in() except SharkIqAuthError: - _LOGGER.error("Authentication error connecting to Shark IQ api") + LOGGER.error("Authentication error connecting to Shark IQ api") return False except asyncio.TimeoutError as exc: - _LOGGER.error("Timeout expired") + LOGGER.error("Timeout expired") raise CannotConnect from exc return True @@ -57,7 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b shark_vacs = await ayla_api.async_get_devices(False) device_names = ", ".join(d.name for d in shark_vacs) - _LOGGER.debug("Found %d Shark IQ device(s): %s", len(shark_vacs), device_names) + LOGGER.debug("Found %d Shark IQ device(s): %s", len(shark_vacs), device_names) coordinator = SharkIqUpdateCoordinator(hass, config_entry, ayla_api, shark_vacs) await coordinator.async_config_entry_first_refresh() @@ -72,7 +72,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b async def async_disconnect_or_timeout(coordinator: SharkIqUpdateCoordinator): """Disconnect to vacuum.""" - _LOGGER.debug("Disconnecting from Ayla Api") + LOGGER.debug("Disconnecting from Ayla Api") async with async_timeout.timeout(5): with suppress( SharkIqAuthError, SharkIqAuthExpiringError, SharkIqNotAuthedError diff --git a/homeassistant/components/sharkiq/config_flow.py b/homeassistant/components/sharkiq/config_flow.py index fb415bc9508..53a8ec480fa 100644 --- a/homeassistant/components/sharkiq/config_flow.py +++ b/homeassistant/components/sharkiq/config_flow.py @@ -12,7 +12,7 @@ from homeassistant import config_entries, core, exceptions from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.helpers.aiohttp_client import async_get_clientsession -from .const import _LOGGER, DOMAIN +from .const import DOMAIN, LOGGER SHARKIQ_SCHEMA = vol.Schema( {vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str} @@ -29,7 +29,7 @@ async def validate_input(hass: core.HomeAssistant, data): try: async with async_timeout.timeout(10): - _LOGGER.debug("Initialize connection to Ayla networks API") + LOGGER.debug("Initialize connection to Ayla networks API") await ayla_api.async_sign_in() except (asyncio.TimeoutError, aiohttp.ClientError) as errors: raise CannotConnect from errors @@ -58,7 +58,7 @@ class SharkIqConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except InvalidAuth: errors["base"] = "invalid_auth" except Exception: # pylint: disable=broad-except - _LOGGER.exception("Unexpected exception") + LOGGER.exception("Unexpected exception") errors["base"] = "unknown" return info, errors diff --git a/homeassistant/components/sharkiq/const.py b/homeassistant/components/sharkiq/const.py index 166e165bd70..fb683bb525a 100644 --- a/homeassistant/components/sharkiq/const.py +++ b/homeassistant/components/sharkiq/const.py @@ -4,7 +4,7 @@ import logging from homeassistant.const import Platform -_LOGGER = logging.getLogger(__package__) +LOGGER = logging.getLogger(__package__) API_TIMEOUT = 20 PLATFORMS = [Platform.VACUUM] diff --git a/homeassistant/components/sharkiq/update_coordinator.py b/homeassistant/components/sharkiq/update_coordinator.py index 7244734b105..08e383a7437 100644 --- a/homeassistant/components/sharkiq/update_coordinator.py +++ b/homeassistant/components/sharkiq/update_coordinator.py @@ -17,7 +17,7 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed -from .const import _LOGGER, API_TIMEOUT, DOMAIN, UPDATE_INTERVAL +from .const import API_TIMEOUT, DOMAIN, LOGGER, UPDATE_INTERVAL class SharkIqUpdateCoordinator(DataUpdateCoordinator): @@ -38,7 +38,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator): self._config_entry = config_entry self._online_dsns: set[str] = set() - super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL) + super().__init__(hass, LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL) @property def online_dsns(self) -> set[str]: @@ -53,7 +53,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator): async def _async_update_vacuum(sharkiq: SharkIqVacuum) -> None: """Asynchronously update the data for a single vacuum.""" dsn = sharkiq.serial_number - _LOGGER.debug("Updating sharkiq data for device DSN %s", dsn) + LOGGER.debug("Updating sharkiq data for device DSN %s", dsn) async with timeout(API_TIMEOUT): await sharkiq.async_update() @@ -67,7 +67,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator): if v["connection_status"] == "Online" and v["dsn"] in self.shark_vacs } - _LOGGER.debug("Updating sharkiq data") + LOGGER.debug("Updating sharkiq data") online_vacs = (self.shark_vacs[dsn] for dsn in self.online_dsns) await asyncio.gather(*(self._async_update_vacuum(v) for v in online_vacs)) except ( @@ -75,10 +75,10 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator): SharkIqNotAuthedError, SharkIqAuthExpiringError, ) as err: - _LOGGER.debug("Bad auth state. Attempting re-auth", exc_info=err) + LOGGER.debug("Bad auth state. Attempting re-auth", exc_info=err) raise ConfigEntryAuthFailed from err except Exception as err: - _LOGGER.exception("Unexpected error updating SharkIQ") + LOGGER.exception("Unexpected error updating SharkIQ") raise UpdateFailed(err) from err return True diff --git a/homeassistant/components/sharkiq/vacuum.py b/homeassistant/components/sharkiq/vacuum.py index 3fb7eccac3d..d9d22eb7a4d 100644 --- a/homeassistant/components/sharkiq/vacuum.py +++ b/homeassistant/components/sharkiq/vacuum.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Iterable -import logging from sharkiqpy import OperatingModes, PowerModes, Properties, SharkIqVacuum @@ -29,11 +28,9 @@ from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DOMAIN, SHARK +from .const import DOMAIN, LOGGER, SHARK from .update_coordinator import SharkIqUpdateCoordinator -_LOGGER = logging.getLogger(__name__) - # Supported features SUPPORT_SHARKIQ = ( SUPPORT_BATTERY @@ -79,7 +76,7 @@ async def async_setup_entry( coordinator: SharkIqUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] devices: Iterable[SharkIqVacuum] = coordinator.shark_vacs.values() device_names = [d.name for d in devices] - _LOGGER.debug( + LOGGER.debug( "Found %d Shark IQ device(s): %s", len(device_names), ", ".join([d.name for d in devices]),