mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 23:57:06 +00:00
Use LOGGER from homewizard.const instead per-file loggers (#135320)
This commit is contained in:
parent
bf747bb733
commit
00c3b8cc3e
@ -3,7 +3,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
|
||||||
from typing import Any, NamedTuple
|
from typing import Any, NamedTuple
|
||||||
|
|
||||||
from homewizard_energy import HomeWizardEnergyV1
|
from homewizard_energy import HomeWizardEnergyV1
|
||||||
@ -25,10 +24,9 @@ from .const import (
|
|||||||
CONF_PRODUCT_TYPE,
|
CONF_PRODUCT_TYPE,
|
||||||
CONF_SERIAL,
|
CONF_SERIAL,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
LOGGER,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class DiscoveryData(NamedTuple):
|
class DiscoveryData(NamedTuple):
|
||||||
"""User metadata."""
|
"""User metadata."""
|
||||||
@ -55,7 +53,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
device_info = await self._async_try_connect(user_input[CONF_IP_ADDRESS])
|
device_info = await self._async_try_connect(user_input[CONF_IP_ADDRESS])
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
_LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
errors = {"base": ex.error_code}
|
errors = {"base": ex.error_code}
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
@ -122,7 +120,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
device = await self._async_try_connect(discovery_info.ip)
|
device = await self._async_try_connect(discovery_info.ip)
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
_LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
|
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
@ -147,7 +145,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
await self._async_try_connect(self.discovery.ip)
|
await self._async_try_connect(self.discovery.ip)
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
_LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
errors = {"base": ex.error_code}
|
errors = {"base": ex.error_code}
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
@ -190,7 +188,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
await self._async_try_connect(reauth_entry.data[CONF_IP_ADDRESS])
|
await self._async_try_connect(reauth_entry.data[CONF_IP_ADDRESS])
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
_LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
errors = {"base": ex.error_code}
|
errors = {"base": ex.error_code}
|
||||||
else:
|
else:
|
||||||
await self.hass.config_entries.async_reload(reauth_entry.entry_id)
|
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])
|
device_info = await self._async_try_connect(user_input[CONF_IP_ADDRESS])
|
||||||
|
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
_LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
errors = {"base": ex.error_code}
|
errors = {"base": ex.error_code}
|
||||||
else:
|
else:
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
@ -253,7 +251,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) from ex
|
) from ex
|
||||||
|
|
||||||
except UnsupportedError as ex:
|
except UnsupportedError as ex:
|
||||||
_LOGGER.error("API version unsuppored")
|
LOGGER.error("API version unsuppored")
|
||||||
raise AbortFlow("unsupported_api_version") from ex
|
raise AbortFlow("unsupported_api_version") from ex
|
||||||
|
|
||||||
except RequestError as ex:
|
except RequestError as ex:
|
||||||
@ -262,7 +260,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) from ex
|
) from ex
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
_LOGGER.exception("Unexpected exception")
|
LOGGER.exception("Unexpected exception")
|
||||||
raise AbortFlow("unknown_error") from ex
|
raise AbortFlow("unknown_error") from ex
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from homewizard_energy import HomeWizardEnergy, HomeWizardEnergyV1
|
from homewizard_energy import HomeWizardEnergy, HomeWizardEnergyV1
|
||||||
from homewizard_energy.errors import DisabledError, RequestError
|
from homewizard_energy.errors import DisabledError, RequestError
|
||||||
from homewizard_energy.models import CombinedModels as DeviceResponseEntry
|
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.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import DOMAIN, UPDATE_INTERVAL
|
from .const import DOMAIN, LOGGER, UPDATE_INTERVAL
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]):
|
class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]):
|
||||||
@ -32,7 +28,7 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize update coordinator."""
|
"""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.api = HomeWizardEnergyV1(
|
||||||
self.config_entry.data[CONF_IP_ADDRESS],
|
self.config_entry.data[CONF_IP_ADDRESS],
|
||||||
clientsession=async_get_clientsession(hass),
|
clientsession=async_get_clientsession(hass),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user