mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Make _LOGGER public in Vodafone Station (#177381)
This commit is contained in:
@@ -6,7 +6,7 @@ from aiovodafone.models import get_device_type
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import _LOGGER, CONF_DEVICE_DETAILS, DEVICE_TYPE, DEVICE_URL
|
||||
from .const import CONF_DEVICE_DETAILS, DEVICE_TYPE, DEVICE_URL, LOGGER
|
||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||
|
||||
PLATFORMS = [
|
||||
@@ -39,9 +39,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -
|
||||
"""Migrate old entry."""
|
||||
|
||||
if entry.version == 1 and entry.minor_version == 1:
|
||||
_LOGGER.debug(
|
||||
"Migrating from version %s.%s", entry.version, entry.minor_version
|
||||
)
|
||||
LOGGER.debug("Migrating from version %s.%s", entry.version, entry.minor_version)
|
||||
|
||||
jar = CookieJar(unsafe=True, quote_cookie=False)
|
||||
session = ClientSession(cookie_jar=jar)
|
||||
@@ -69,7 +67,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -
|
||||
entry, data=new_data, version=1, minor_version=2
|
||||
)
|
||||
|
||||
_LOGGER.info(
|
||||
LOGGER.info(
|
||||
"Migration to version %s.%s successful", entry.version, entry.minor_version
|
||||
)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import _LOGGER, DOMAIN
|
||||
from .const import DOMAIN, LOGGER
|
||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||
|
||||
# Coordinator is used to centralize the data updates
|
||||
@@ -81,7 +81,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up entry."""
|
||||
_LOGGER.debug("Setting up Vodafone Station buttons")
|
||||
LOGGER.debug("Setting up Vodafone Station buttons")
|
||||
|
||||
coordinator = entry.runtime_data
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
from .const import (
|
||||
_LOGGER,
|
||||
CONF_DEVICE_DETAILS,
|
||||
DEFAULT_HOST,
|
||||
DEFAULT_USERNAME,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_URL,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
)
|
||||
from .coordinator import VodafoneConfigEntry
|
||||
from .utils import async_client_session
|
||||
@@ -114,7 +114,7 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except aiovodafone_exceptions.ModelNotSupported:
|
||||
errors["base"] = "model_not_supported"
|
||||
except Exception: # noqa: BLE001
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
return self.async_create_entry(
|
||||
@@ -150,7 +150,7 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except aiovodafone_exceptions.CannotAuthenticate:
|
||||
errors["base"] = "invalid_auth"
|
||||
except Exception: # noqa: BLE001
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
return self.async_update_reload_and_abort(
|
||||
@@ -193,7 +193,7 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except aiovodafone_exceptions.CannotAuthenticate:
|
||||
errors["base"] = "invalid_auth"
|
||||
except Exception: # noqa: BLE001
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
return self.async_update_reload_and_abort(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
_LOGGER = logging.getLogger(__package__)
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
|
||||
DOMAIN = "vodafone_station"
|
||||
SCAN_INTERVAL = 30
|
||||
|
||||
@@ -25,11 +25,11 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import (
|
||||
_LOGGER,
|
||||
CONF_DEVICE_DETAILS,
|
||||
DEVICE_TYPE,
|
||||
DEVICE_URL,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
SCAN_INTERVAL,
|
||||
)
|
||||
from .helpers import cleanup_device_tracker
|
||||
@@ -77,7 +77,7 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
logger=LOGGER,
|
||||
name=f"{DOMAIN}-{config_entry.data[CONF_HOST]}-coordinator",
|
||||
update_interval=timedelta(seconds=SCAN_INTERVAL),
|
||||
config_entry=config_entry,
|
||||
@@ -126,11 +126,11 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
@override
|
||||
async def _async_update_data(self) -> UpdateCoordinatorDataType:
|
||||
"""Update router data."""
|
||||
_LOGGER.debug("Polling Vodafone Station host: %s", self.api.base_url.host)
|
||||
LOGGER.debug("Polling Vodafone Station host: %s", self.api.base_url.host)
|
||||
|
||||
try:
|
||||
if not self._session.cookie_jar.filter_cookies(self.api.base_url):
|
||||
_LOGGER.debug(
|
||||
LOGGER.debug(
|
||||
"Session cookies missing for host %s, re-login",
|
||||
self.api.base_url.host,
|
||||
)
|
||||
@@ -152,7 +152,7 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
# Plain html response (usually occurs after
|
||||
# a firmware update), requiring session
|
||||
# reinitialization
|
||||
_LOGGER.info("Stale session detected, reinitializing API session")
|
||||
LOGGER.info("Stale session detected, reinitializing API session")
|
||||
await self.initialize_api()
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN,
|
||||
@@ -171,11 +171,11 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
for dev_info in (raw_data_devices).values()
|
||||
}
|
||||
current_devices = set(data_devices)
|
||||
_LOGGER.debug(
|
||||
LOGGER.debug(
|
||||
"Loaded current %s devices: %s", len(current_devices), current_devices
|
||||
)
|
||||
if stale_devices := self.previous_devices - current_devices:
|
||||
_LOGGER.debug(
|
||||
LOGGER.debug(
|
||||
"Found %s stale devices: %s", len(stale_devices), stale_devices
|
||||
)
|
||||
await cleanup_device_tracker(self.hass, self.config_entry, data_devices)
|
||||
|
||||
@@ -8,7 +8,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import _LOGGER
|
||||
from .const import LOGGER
|
||||
from .coordinator import (
|
||||
VodafoneConfigEntry,
|
||||
VodafoneStationDeviceInfo,
|
||||
@@ -26,7 +26,7 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""Set up device tracker for Vodafone Station component."""
|
||||
|
||||
_LOGGER.debug("Start device trackers setup")
|
||||
LOGGER.debug("Start device trackers setup")
|
||||
coordinator = entry.runtime_data
|
||||
|
||||
tracked: set = set()
|
||||
@@ -54,11 +54,11 @@ def async_add_new_tracked_entities(
|
||||
"""Add new tracker entities from the router."""
|
||||
new_tracked = []
|
||||
|
||||
_LOGGER.debug("Adding device trackers entities")
|
||||
LOGGER.debug("Adding device trackers entities")
|
||||
for mac, device_info in coordinator.data.devices.items():
|
||||
if mac in tracked:
|
||||
continue
|
||||
_LOGGER.debug("New device tracker: %s", device_info.device.name)
|
||||
LOGGER.debug("New device tracker: %s", device_info.device.name)
|
||||
new_tracked.append(VodafoneStationTracker(coordinator, device_info))
|
||||
tracked.add(mac)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from .const import _LOGGER
|
||||
from .const import LOGGER
|
||||
|
||||
|
||||
async def cleanup_device_tracker(
|
||||
@@ -39,7 +39,7 @@ async def cleanup_device_tracker(
|
||||
and entry_host in device_hosts_names
|
||||
and entry_mac in device_hosts_macs
|
||||
):
|
||||
_LOGGER.debug(
|
||||
LOGGER.debug(
|
||||
"Skipping entity %s [mac=%s, host=%s]",
|
||||
entry_name,
|
||||
entry_mac,
|
||||
@@ -48,7 +48,7 @@ async def cleanup_device_tracker(
|
||||
continue
|
||||
# Entity is removed so that at the next coordinator update
|
||||
# the correct one will be created
|
||||
_LOGGER.info("Removing entity: %s", entry_name)
|
||||
LOGGER.info("Removing entity: %s", entry_name)
|
||||
entity_reg.async_remove(entry.entity_id)
|
||||
entities_removed = True
|
||||
|
||||
@@ -69,5 +69,5 @@ def _async_remove_empty_devices(
|
||||
device_entry.id,
|
||||
include_disabled_entities=True,
|
||||
):
|
||||
_LOGGER.info("Removing device: %s", device_entry.name)
|
||||
LOGGER.info("Removing device: %s", device_entry.name)
|
||||
device_reg.async_remove_device(device_entry.id)
|
||||
|
||||
@@ -12,7 +12,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import _LOGGER
|
||||
from .const import LOGGER
|
||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||
|
||||
# Coordinator is used to centralize the data updates
|
||||
@@ -37,7 +37,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Guest WiFi QR code for device."""
|
||||
_LOGGER.debug("Setting up Vodafone Station images")
|
||||
LOGGER.debug("Setting up Vodafone Station images")
|
||||
|
||||
coordinator = entry.runtime_data
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import _LOGGER, LINE_TYPES
|
||||
from .const import LINE_TYPES, LOGGER
|
||||
from .coordinator import VodafoneConfigEntry, VodafoneStationRouter
|
||||
|
||||
# Coordinator is used to centralize the data updates
|
||||
@@ -152,7 +152,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up entry."""
|
||||
_LOGGER.debug("Setting up Vodafone Station sensors")
|
||||
LOGGER.debug("Setting up Vodafone Station sensors")
|
||||
|
||||
coordinator = entry.runtime_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user