mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Move Flo logger to a package logger (#43449)
This commit is contained in:
parent
dd4f41c1db
commit
a880ef6a4e
@ -1,6 +1,4 @@
|
|||||||
"""Config flow for flo integration."""
|
"""Config flow for flo integration."""
|
||||||
import logging
|
|
||||||
|
|
||||||
from aioflo import async_get_api
|
from aioflo import async_get_api
|
||||||
from aioflo.errors import RequestError
|
from aioflo.errors import RequestError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -9,9 +7,7 @@ from homeassistant import config_entries, core, exceptions
|
|||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN # pylint:disable=unused-import
|
from .const import DOMAIN, LOGGER # pylint:disable=unused-import
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema({"username": str, "password": str})
|
DATA_SCHEMA = vol.Schema({"username": str, "password": str})
|
||||||
|
|
||||||
@ -28,7 +24,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
data[CONF_USERNAME], data[CONF_PASSWORD], session=session
|
data[CONF_USERNAME], data[CONF_PASSWORD], session=session
|
||||||
)
|
)
|
||||||
except RequestError as request_error:
|
except RequestError as request_error:
|
||||||
_LOGGER.error("Error connecting to the Flo API: %s", request_error)
|
LOGGER.error("Error connecting to the Flo API: %s", request_error)
|
||||||
raise CannotConnect from request_error
|
raise CannotConnect from request_error
|
||||||
|
|
||||||
user_info = await api.user.get_info()
|
user_info = await api.user.get_info()
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
"""Constants for the flo integration."""
|
"""Constants for the flo integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
CLIENT = "client"
|
CLIENT = "client"
|
||||||
DOMAIN = "flo"
|
DOMAIN = "flo"
|
||||||
FLO_HOME = "home"
|
FLO_HOME = "home"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Flo device object."""
|
"""Flo device object."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from aioflo.api import API
|
from aioflo.api import API
|
||||||
@ -12,9 +11,7 @@ from homeassistant.helpers.typing import HomeAssistantType
|
|||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import DOMAIN as FLO_DOMAIN
|
from .const import DOMAIN as FLO_DOMAIN, LOGGER
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
@ -33,7 +30,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
self._water_usage: Optional[Dict[str, Any]] = None
|
self._water_usage: Optional[Dict[str, Any]] = None
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
LOGGER,
|
||||||
name=f"{FLO_DOMAIN}-{device_id}",
|
name=f"{FLO_DOMAIN}-{device_id}",
|
||||||
update_interval=timedelta(seconds=60),
|
update_interval=timedelta(seconds=60),
|
||||||
)
|
)
|
||||||
@ -195,7 +192,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
self._device_information = await self.api_client.device.get_info(
|
self._device_information = await self.api_client.device.get_info(
|
||||||
self._flo_device_id
|
self._flo_device_id
|
||||||
)
|
)
|
||||||
_LOGGER.debug("Flo device data: %s", self._device_information)
|
LOGGER.debug("Flo device data: %s", self._device_information)
|
||||||
|
|
||||||
async def _update_consumption_data(self, *_) -> None:
|
async def _update_consumption_data(self, *_) -> None:
|
||||||
"""Update water consumption data from the API."""
|
"""Update water consumption data from the API."""
|
||||||
@ -205,4 +202,4 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
self._water_usage = await self.api_client.water.get_consumption_info(
|
self._water_usage = await self.api_client.water.get_consumption_info(
|
||||||
self._flo_location_id, start_date, end_date
|
self._flo_location_id, start_date, end_date
|
||||||
)
|
)
|
||||||
_LOGGER.debug("Updated Flo consumption data: %s", self._water_usage)
|
LOGGER.debug("Updated Flo consumption data: %s", self._water_usage)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user