mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move Notion logger to a package logger (#43450)
This commit is contained in:
parent
22f63be30e
commit
b4381c5005
@ -1,7 +1,6 @@
|
|||||||
"""Support for Notion."""
|
"""Support for Notion."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
|
||||||
|
|
||||||
from aionotion import async_get_client
|
from aionotion import async_get_client
|
||||||
from aionotion.errors import InvalidCredentialsError, NotionError
|
from aionotion.errors import InvalidCredentialsError, NotionError
|
||||||
@ -21,9 +20,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||||||
UpdateFailed,
|
UpdateFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import DATA_COORDINATOR, DOMAIN
|
from .const import DATA_COORDINATOR, DOMAIN, LOGGER
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
PLATFORMS = ["binary_sensor", "sensor"]
|
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
|
entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], session
|
||||||
)
|
)
|
||||||
except InvalidCredentialsError:
|
except InvalidCredentialsError:
|
||||||
_LOGGER.error("Invalid username and/or password")
|
LOGGER.error("Invalid username and/or password")
|
||||||
return False
|
return False
|
||||||
except NotionError as err:
|
except NotionError as err:
|
||||||
_LOGGER.error("Config entry failed: %s", err)
|
LOGGER.error("Config entry failed: %s", err)
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
async def async_update():
|
async def async_update():
|
||||||
@ -94,7 +91,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
entry.entry_id
|
entry.entry_id
|
||||||
] = DataUpdateCoordinator(
|
] = DataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
LOGGER,
|
||||||
name=entry.data[CONF_USERNAME],
|
name=entry.data[CONF_USERNAME],
|
||||||
update_interval=DEFAULT_SCAN_INTERVAL,
|
update_interval=DEFAULT_SCAN_INTERVAL,
|
||||||
update_method=async_update,
|
update_method=async_update,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
"""Define constants for the Notion integration."""
|
"""Define constants for the Notion integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
DOMAIN = "notion"
|
DOMAIN = "notion"
|
||||||
|
LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
DATA_COORDINATOR = "coordinator"
|
DATA_COORDINATOR = "coordinator"
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for Notion sensors."""
|
"""Support for Notion sensors."""
|
||||||
import logging
|
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -8,9 +7,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from . import NotionEntity
|
from . import NotionEntity
|
||||||
from .const import DATA_COORDINATOR, DOMAIN, SENSOR_TEMPERATURE
|
from .const import DATA_COORDINATOR, DOMAIN, LOGGER, SENSOR_TEMPERATURE
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
SENSOR_TYPES = {SENSOR_TEMPERATURE: ("Temperature", "temperature", TEMP_CELSIUS)}
|
SENSOR_TYPES = {SENSOR_TEMPERATURE: ("Temperature", "temperature", TEMP_CELSIUS)}
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ class NotionSensor(NotionEntity):
|
|||||||
if task["task_type"] == SENSOR_TEMPERATURE:
|
if task["task_type"] == SENSOR_TEMPERATURE:
|
||||||
self._state = round(float(task["status"]["value"]), 1)
|
self._state = round(float(task["status"]["value"]), 1)
|
||||||
else:
|
else:
|
||||||
_LOGGER.error(
|
LOGGER.error(
|
||||||
"Unknown task type: %s: %s",
|
"Unknown task type: %s: %s",
|
||||||
self.coordinator.data["sensors"][self._sensor_id],
|
self.coordinator.data["sensors"][self._sensor_id],
|
||||||
task["task_type"],
|
task["task_type"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user