Move Notion logger to a package logger (#43450)
This commit is contained in:
parent
22f63be30e
commit
b4381c5005
3 changed files with 9 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Support for Notion."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from aionotion import async_get_client
|
||||
from aionotion.errors import InvalidCredentialsError, NotionError
|
||||
|
@ -21,9 +20,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
UpdateFailed,
|
||||
)
|
||||
|
||||
from .const import DATA_COORDINATOR, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
from .const import DATA_COORDINATOR, DOMAIN, LOGGER
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor"]
|
||||
|
||||
|
@ -56,10 +53,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], session
|
||||
)
|
||||
except InvalidCredentialsError:
|
||||
_LOGGER.error("Invalid username and/or password")
|
||||
LOGGER.error("Invalid username and/or password")
|
||||
return False
|
||||
except NotionError as err:
|
||||
_LOGGER.error("Config entry failed: %s", err)
|
||||
LOGGER.error("Config entry failed: %s", err)
|
||||
raise ConfigEntryNotReady from err
|
||||
|
||||
async def async_update():
|
||||
|
@ -94,7 +91,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
entry.entry_id
|
||||
] = DataUpdateCoordinator(
|
||||
hass,
|
||||
_LOGGER,
|
||||
LOGGER,
|
||||
name=entry.data[CONF_USERNAME],
|
||||
update_interval=DEFAULT_SCAN_INTERVAL,
|
||||
update_method=async_update,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"""Define constants for the Notion integration."""
|
||||
import logging
|
||||
|
||||
DOMAIN = "notion"
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
|
||||
DATA_COORDINATOR = "coordinator"
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Support for Notion sensors."""
|
||||
import logging
|
||||
from typing import Callable
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -8,9 +7,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from . import NotionEntity
|
||||
from .const import DATA_COORDINATOR, DOMAIN, SENSOR_TEMPERATURE
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
from .const import DATA_COORDINATOR, DOMAIN, LOGGER, SENSOR_TEMPERATURE
|
||||
|
||||
SENSOR_TYPES = {SENSOR_TEMPERATURE: ("Temperature", "temperature", TEMP_CELSIUS)}
|
||||
|
||||
|
@ -84,7 +81,7 @@ class NotionSensor(NotionEntity):
|
|||
if task["task_type"] == SENSOR_TEMPERATURE:
|
||||
self._state = round(float(task["status"]["value"]), 1)
|
||||
else:
|
||||
_LOGGER.error(
|
||||
LOGGER.error(
|
||||
"Unknown task type: %s: %s",
|
||||
self.coordinator.data["sensors"][self._sensor_id],
|
||||
task["task_type"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue