diff --git a/homeassistant/auth/auth_store.py b/homeassistant/auth/auth_store.py index 8b8531b4aff6..d1760465c321 100644 --- a/homeassistant/auth/auth_store.py +++ b/homeassistant/auth/auth_store.py @@ -18,7 +18,8 @@ from .const import ( GROUP_ID_READ_ONLY, GROUP_ID_USER, ) -from .permissions import PermissionLookup, system_policies +from .permissions import system_policies +from .permissions.models import PermissionLookup from .permissions.types import PolicyType # mypy: disallow-any-generics diff --git a/homeassistant/components/cast/home_assistant_cast.py b/homeassistant/components/cast/home_assistant_cast.py index 417809e4894f..0f312d6a37a7 100644 --- a/homeassistant/components/cast/home_assistant_cast.py +++ b/homeassistant/components/cast/home_assistant_cast.py @@ -28,7 +28,7 @@ async def async_setup_ha_cast( if user is None: user = await hass.auth.async_create_system_user( - "Home Assistant Cast", group_ids=[auth.GROUP_ID_ADMIN] + "Home Assistant Cast", group_ids=[auth.const.GROUP_ID_ADMIN] ) hass.config_entries.async_update_entry( entry, data={**entry.data, "user_id": user.id} diff --git a/homeassistant/components/humidifier/device_action.py b/homeassistant/components/humidifier/device_action.py index d8f13d31b557..5ff79bdf2beb 100644 --- a/homeassistant/components/humidifier/device_action.py +++ b/homeassistant/components/humidifier/device_action.py @@ -14,7 +14,8 @@ from homeassistant.const import ( CONF_ENTITY_ID, CONF_TYPE, ) -from homeassistant.core import Context, HomeAssistant, HomeAssistantError +from homeassistant.core import Context, HomeAssistant +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import get_capability, get_supported_features diff --git a/homeassistant/components/humidifier/device_condition.py b/homeassistant/components/humidifier/device_condition.py index a8baf4f49103..323d199cfc66 100644 --- a/homeassistant/components/humidifier/device_condition.py +++ b/homeassistant/components/humidifier/device_condition.py @@ -13,7 +13,8 @@ from homeassistant.const import ( CONF_ENTITY_ID, CONF_TYPE, ) -from homeassistant.core import HomeAssistant, HomeAssistantError, callback +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.entity import get_capability, get_supported_features diff --git a/homeassistant/components/nissan_leaf/sensor.py b/homeassistant/components/nissan_leaf/sensor.py index bff40522f816..64847e3fa5c7 100644 --- a/homeassistant/components/nissan_leaf/sensor.py +++ b/homeassistant/components/nissan_leaf/sensor.py @@ -7,12 +7,11 @@ from pycarwings2.pycarwings2 import Leaf from voluptuous.validators import Number from homeassistant.components.sensor import SensorDeviceClass, SensorEntity -from homeassistant.const import PERCENTAGE +from homeassistant.const import LENGTH_KILOMETERS, LENGTH_MILES, PERCENTAGE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from homeassistant.util.distance import LENGTH_KILOMETERS, LENGTH_MILES from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from . import LeafEntity diff --git a/homeassistant/components/person/__init__.py b/homeassistant/components/person/__init__.py index 983519515050..2f850b2cb84a 100644 --- a/homeassistant/components/person/__init__.py +++ b/homeassistant/components/person/__init__.py @@ -119,7 +119,7 @@ async def async_add_user_device_tracker( return await coll.async_update_item( - person[collection.CONF_ID], + person[CONF_ID], {CONF_DEVICE_TRACKERS: device_trackers + [device_tracker_entity_id]}, ) break @@ -212,7 +212,7 @@ class PersonStorageCollection(collection.StorageCollection): continue await self.async_update_item( - person[collection.CONF_ID], + person[CONF_ID], { CONF_DEVICE_TRACKERS: [ devt @@ -268,10 +268,10 @@ async def filter_yaml_data(hass: HomeAssistant, persons: list[dict]) -> list[dic if user_id is not None and await hass.auth.async_get_user(user_id) is None: _LOGGER.error( "Invalid user_id detected for person %s", - person_conf[collection.CONF_ID], + person_conf[CONF_ID], ) person_invalid_user.append( - f"- Person {person_conf[CONF_NAME]} (id: {person_conf[collection.CONF_ID]}) points at invalid user {user_id}" + f"- Person {person_conf[CONF_NAME]} (id: {person_conf[CONF_ID]}) points at invalid user {user_id}" ) continue diff --git a/homeassistant/components/pvpc_hourly_pricing/sensor.py b/homeassistant/components/pvpc_hourly_pricing/sensor.py index c1925fa12ffc..6d9ac9402e6a 100644 --- a/homeassistant/components/pvpc_hourly_pricing/sensor.py +++ b/homeassistant/components/pvpc_hourly_pricing/sensor.py @@ -14,7 +14,8 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, CURRENCY_EURO, ENERGY_KILO_WATT_HOUR from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers.entity import DeviceEntryType, DeviceInfo +from homeassistant.helpers.device_registry import DeviceEntryType +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_track_time_change from homeassistant.helpers.typing import StateType diff --git a/homeassistant/components/smart_meter_texas/__init__.py b/homeassistant/components/smart_meter_texas/__init__.py index b3ee4f807ba8..cd83a1e51c11 100644 --- a/homeassistant/components/smart_meter_texas/__init__.py +++ b/homeassistant/components/smart_meter_texas/__init__.py @@ -14,11 +14,8 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import aiohttp_client -from homeassistant.helpers.update_coordinator import ( - DataUpdateCoordinator, - Debouncer, - UpdateFailed, -) +from homeassistant.helpers.debounce import Debouncer +from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import ( DATA_COORDINATOR, diff --git a/homeassistant/components/trend/binary_sensor.py b/homeassistant/components/trend/binary_sensor.py index 98b7de448f29..87aadc784153 100644 --- a/homeassistant/components/trend/binary_sensor.py +++ b/homeassistant/components/trend/binary_sensor.py @@ -32,7 +32,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.reload import setup_reload_service from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from homeassistant.util import utcnow +from homeassistant.util.dt import utcnow from . import DOMAIN, PLATFORMS diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index 0e619fe551b8..c1d7487abb68 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -6,9 +6,10 @@ from collections.abc import Awaitable, Callable import logging from typing import Any +from homeassistant.const import EVENT_COMPONENT_LOADED from homeassistant.core import Event, HomeAssistant from homeassistant.loader import async_get_integration, bind_hass -from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED +from homeassistant.setup import ATTR_COMPONENT _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/helpers/restore_state.py b/homeassistant/helpers/restore_state.py index 19b1509c162b..4857210f125e 100644 --- a/homeassistant/helpers/restore_state.py +++ b/homeassistant/helpers/restore_state.py @@ -6,12 +6,12 @@ from datetime import datetime, timedelta import logging from typing import Any, TypeVar, cast -from homeassistant.const import EVENT_HOMEASSISTANT_STOP +from homeassistant.const import ATTR_RESTORED, EVENT_HOMEASSISTANT_STOP from homeassistant.core import HomeAssistant, State, callback, valid_entity_id from homeassistant.exceptions import HomeAssistantError import homeassistant.util.dt as dt_util -from . import entity_registry, start +from . import start from .entity import Entity from .event import async_track_time_interval from .json import JSONEncoder @@ -120,7 +120,7 @@ class RestoreStateData: current_entity_ids = { state.entity_id for state in all_states - if not state.attributes.get(entity_registry.ATTR_RESTORED) + if not state.attributes.get(ATTR_RESTORED) } # Start with the currently registered states @@ -129,7 +129,7 @@ class RestoreStateData: for state in all_states if state.entity_id in self.entity_ids and # Ignore all states that are entity registry placeholders - not state.attributes.get(entity_registry.ATTR_RESTORED) + not state.attributes.get(ATTR_RESTORED) ] expiration_time = now - STATE_EXPIRATION