Use LOGGER from homewizard.const instead per-file loggers (#135320)

pull/135331/head
Duco Sebel 2025-01-10 22:49:36 +01:00 committed by GitHub
parent bf747bb733
commit 00c3b8cc3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 16 deletions

View File

@ -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
@ -25,10 +24,9 @@ from .const import (
CONF_PRODUCT_TYPE,
CONF_SERIAL,
DOMAIN,
LOGGER,
)
_LOGGER = logging.getLogger(__name__)
class DiscoveryData(NamedTuple):
"""User metadata."""
@ -55,7 +53,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -122,7 +120,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -147,7 +145,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -190,7 +188,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
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)
@ -208,7 +206,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -253,7 +251,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
) 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:
@ -262,7 +260,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
) from ex
except Exception as ex:
_LOGGER.exception("Unexpected exception")
LOGGER.exception("Unexpected exception")
raise AbortFlow("unknown_error") from ex
finally:

View File

@ -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
@ -14,9 +12,7 @@ from homeassistant.core import HomeAssistant
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]):
@ -32,7 +28,7 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
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),