1
mirror of https://github.com/home-assistant/core synced 2024-08-31 05:57:13 +02:00

Move Flo logger to a package logger (#43449)

This commit is contained in:
Aaron Bach 2020-11-20 13:14:44 -07:00 committed by GitHub
parent dd4f41c1db
commit a880ef6a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 13 deletions

View File

@ -1,6 +1,4 @@
"""Config flow for flo integration."""
import logging
from aioflo import async_get_api
from aioflo.errors import RequestError
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.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN # pylint:disable=unused-import
_LOGGER = logging.getLogger(__name__)
from .const import DOMAIN, LOGGER # pylint:disable=unused-import
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
)
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
user_info = await api.user.get_info()

View File

@ -1,4 +1,8 @@
"""Constants for the flo integration."""
import logging
LOGGER = logging.getLogger(__package__)
CLIENT = "client"
DOMAIN = "flo"
FLO_HOME = "home"

View File

@ -1,7 +1,6 @@
"""Flo device object."""
import asyncio
from datetime import datetime, timedelta
import logging
from typing import Any, Dict, Optional
from aioflo.api import API
@ -12,9 +11,7 @@ from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
import homeassistant.util.dt as dt_util
from .const import DOMAIN as FLO_DOMAIN
_LOGGER = logging.getLogger(__name__)
from .const import DOMAIN as FLO_DOMAIN, LOGGER
class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
@ -33,7 +30,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
self._water_usage: Optional[Dict[str, Any]] = None
super().__init__(
hass,
_LOGGER,
LOGGER,
name=f"{FLO_DOMAIN}-{device_id}",
update_interval=timedelta(seconds=60),
)
@ -195,7 +192,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
self._device_information = await self.api_client.device.get_info(
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:
"""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._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)