Skip to content

Commit

Permalink
Use LOGGER from homewizard.const instead per-file loggers (home-assis…
Browse files Browse the repository at this point in the history
  • Loading branch information
DCSBL authored Jan 10, 2025
1 parent bf747bb commit 00c3b8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
18 changes: 8 additions & 10 deletions homeassistant/components/homewizard/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

from collections.abc import Mapping
import logging
from typing import Any, NamedTuple

from homewizard_energy import HomeWizardEnergyV1
Expand All @@ -25,10 +24,9 @@
CONF_PRODUCT_TYPE,
CONF_SERIAL,
DOMAIN,
LOGGER,
)

_LOGGER = logging.getLogger(__name__)


class DiscoveryData(NamedTuple):
"""User metadata."""
Expand All @@ -55,7 +53,7 @@ async def async_step_user(
try:
device_info = await self._async_try_connect(user_input[CONF_IP_ADDRESS])
except RecoverableError as ex:
_LOGGER.error(ex)
LOGGER.error(ex)
errors = {"base": ex.error_code}
else:
await self.async_set_unique_id(
Expand Down Expand Up @@ -122,7 +120,7 @@ async def async_step_dhcp(
try:
device = await self._async_try_connect(discovery_info.ip)
except RecoverableError as ex:
_LOGGER.error(ex)
LOGGER.error(ex)
return self.async_abort(reason="unknown")

await self.async_set_unique_id(
Expand All @@ -147,7 +145,7 @@ async def async_step_discovery_confirm(
try:
await self._async_try_connect(self.discovery.ip)
except RecoverableError as ex:
_LOGGER.error(ex)
LOGGER.error(ex)
errors = {"base": ex.error_code}
else:
return self.async_create_entry(
Expand Down Expand Up @@ -190,7 +188,7 @@ async def async_step_reauth_confirm(
try:
await self._async_try_connect(reauth_entry.data[CONF_IP_ADDRESS])
except RecoverableError as ex:
_LOGGER.error(ex)
LOGGER.error(ex)
errors = {"base": ex.error_code}
else:
await self.hass.config_entries.async_reload(reauth_entry.entry_id)
Expand All @@ -208,7 +206,7 @@ async def async_step_reconfigure(
device_info = await self._async_try_connect(user_input[CONF_IP_ADDRESS])

except RecoverableError as ex:
_LOGGER.error(ex)
LOGGER.error(ex)
errors = {"base": ex.error_code}
else:
await self.async_set_unique_id(
Expand Down Expand Up @@ -253,7 +251,7 @@ async def _async_try_connect(ip_address: str) -> Device:
) from ex

except UnsupportedError as ex:
_LOGGER.error("API version unsuppored")
LOGGER.error("API version unsuppored")
raise AbortFlow("unsupported_api_version") from ex

except RequestError as ex:
Expand All @@ -262,7 +260,7 @@ async def _async_try_connect(ip_address: str) -> Device:
) from ex

except Exception as ex:
_LOGGER.exception("Unexpected exception")
LOGGER.exception("Unexpected exception")
raise AbortFlow("unknown_error") from ex

finally:
Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/homewizard/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import logging

from homewizard_energy import HomeWizardEnergy, HomeWizardEnergyV1
from homewizard_energy.errors import DisabledError, RequestError
from homewizard_energy.models import CombinedModels as DeviceResponseEntry
Expand All @@ -14,9 +12,7 @@
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .const import DOMAIN, UPDATE_INTERVAL

_LOGGER = logging.getLogger(__name__)
from .const import DOMAIN, LOGGER, UPDATE_INTERVAL


class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]):
Expand All @@ -32,7 +28,7 @@ def __init__(
hass: HomeAssistant,
) -> None:
"""Initialize update coordinator."""
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
super().__init__(hass, LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
self.api = HomeWizardEnergyV1(
self.config_entry.data[CONF_IP_ADDRESS],
clientsession=async_get_clientsession(hass),
Expand Down

0 comments on commit 00c3b8c

Please sign in to comment.