diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 8bbb97925f5..1c4ff6c3f83 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -22,10 +22,6 @@ from homeassistant.components.media_player.const import ( SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, ) -from homeassistant.components.samsungtv.bridge import ( - SamsungTVLegacyBridge, - SamsungTVWSBridge, -) from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant @@ -37,6 +33,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.script import Script from homeassistant.util import dt as dt_util +from .bridge import SamsungTVLegacyBridge, SamsungTVWSBridge from .const import ( CONF_MANUFACTURER, CONF_MODEL, diff --git a/homeassistant/components/select/device_trigger.py b/homeassistant/components/select/device_trigger.py index 2c05b59c5d5..4def656c763 100644 --- a/homeassistant/components/select/device_trigger.py +++ b/homeassistant/components/select/device_trigger.py @@ -17,7 +17,6 @@ from homeassistant.components.homeassistant.triggers.state import ( async_attach_trigger as async_attach_state_trigger, async_validate_trigger_config as async_validate_state_trigger_config, ) -from homeassistant.components.select.const import ATTR_OPTIONS from homeassistant.const import ( CONF_DEVICE_ID, CONF_DOMAIN, @@ -31,6 +30,7 @@ from homeassistant.helpers.entity import get_capability from homeassistant.helpers.typing import ConfigType from . import DOMAIN +from .const import ATTR_OPTIONS TRIGGER_TYPES = {"current_option_changed"} diff --git a/homeassistant/components/select/reproduce_state.py b/homeassistant/components/select/reproduce_state.py index d41fd5dae46..2ff65c11fa3 100644 --- a/homeassistant/components/select/reproduce_state.py +++ b/homeassistant/components/select/reproduce_state.py @@ -6,11 +6,11 @@ from collections.abc import Iterable import logging from typing import Any -from homeassistant.components.select.const import ATTR_OPTIONS from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, HomeAssistant, State from . import ATTR_OPTION, DOMAIN, SERVICE_SELECT_OPTION +from .const import ATTR_OPTIONS _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/recorder.py b/homeassistant/components/sensor/recorder.py index 3cfe8d45b70..9b6c07a323d 100644 --- a/homeassistant/components/sensor/recorder.py +++ b/homeassistant/components/sensor/recorder.py @@ -23,18 +23,6 @@ from homeassistant.components.recorder.models import ( StatisticMetaData, StatisticResult, ) -from homeassistant.components.sensor import ( - ATTR_STATE_CLASS, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_GAS, - DEVICE_CLASS_MONETARY, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL, - STATE_CLASS_TOTAL_INCREASING, - STATE_CLASSES, -) from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_UNIT_OF_MEASUREMENT, @@ -65,7 +53,20 @@ import homeassistant.util.pressure as pressure_util import homeassistant.util.temperature as temperature_util import homeassistant.util.volume as volume_util -from . import ATTR_LAST_RESET, DOMAIN +from . import ( + ATTR_LAST_RESET, + ATTR_STATE_CLASS, + DEVICE_CLASS_ENERGY, + DEVICE_CLASS_GAS, + DEVICE_CLASS_MONETARY, + DEVICE_CLASS_PRESSURE, + DEVICE_CLASS_TEMPERATURE, + DOMAIN, + STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL, + STATE_CLASS_TOTAL_INCREASING, + STATE_CLASSES, +) _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/shelly/binary_sensor.py b/homeassistant/components/shelly/binary_sensor.py index 4a918506b00..737efad923c 100644 --- a/homeassistant/components/shelly/binary_sensor.py +++ b/homeassistant/components/shelly/binary_sensor.py @@ -17,12 +17,12 @@ from homeassistant.components.binary_sensor import ( STATE_ON, BinarySensorEntity, ) -from homeassistant.components.shelly.const import CONF_SLEEP_PERIOD from homeassistant.config_entries import ConfigEntry from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .const import CONF_SLEEP_PERIOD from .entity import ( BlockAttributeDescription, RestAttributeDescription, diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index f2db157ecf2..79d233336e3 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -19,15 +19,13 @@ from homeassistant.components.climate.const import ( SUPPORT_PRESET_MODE, SUPPORT_TARGET_TEMPERATURE, ) -from homeassistant.components.shelly import BlockDeviceWrapper -from homeassistant.components.shelly.entity import ShellyBlockEntity -from homeassistant.components.shelly.utils import get_device_entry_gen from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity +from . import BlockDeviceWrapper from .const import ( AIOSHELLY_DEVICE_TIMEOUT_SEC, BLOCK, @@ -35,6 +33,8 @@ from .const import ( DOMAIN, SHTRV_01_TEMPERATURE_SETTINGS, ) +from .entity import ShellyBlockEntity +from .utils import get_device_entry_gen _LOGGER: Final = logging.getLogger(__name__) diff --git a/homeassistant/components/soma/cover.py b/homeassistant/components/soma/cover.py index 43ea60d372e..d1f5930c02b 100644 --- a/homeassistant/components/soma/cover.py +++ b/homeassistant/components/soma/cover.py @@ -5,7 +5,8 @@ import logging from requests import RequestException from homeassistant.components.cover import ATTR_POSITION, CoverEntity -from homeassistant.components.soma import API, DEVICES, DOMAIN, SomaEntity + +from . import API, DEVICES, DOMAIN, SomaEntity _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/speedtestdotnet/sensor.py b/homeassistant/components/speedtestdotnet/sensor.py index 10071bf9054..aa4cd72f746 100644 --- a/homeassistant/components/speedtestdotnet/sensor.py +++ b/homeassistant/components/speedtestdotnet/sensor.py @@ -4,7 +4,6 @@ from __future__ import annotations from typing import Any, cast from homeassistant.components.sensor import SensorEntity -from homeassistant.components.speedtestdotnet import SpeedTestDataCoordinator from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import HomeAssistant @@ -15,6 +14,7 @@ from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import CoordinatorEntity +from . import SpeedTestDataCoordinator from .const import ( ATTR_BYTES_RECEIVED, ATTR_BYTES_SENT, diff --git a/homeassistant/components/streamlabswater/binary_sensor.py b/homeassistant/components/streamlabswater/binary_sensor.py index a25f5e124e6..d464d686bd7 100644 --- a/homeassistant/components/streamlabswater/binary_sensor.py +++ b/homeassistant/components/streamlabswater/binary_sensor.py @@ -3,9 +3,10 @@ from datetime import timedelta from homeassistant.components.binary_sensor import BinarySensorEntity -from homeassistant.components.streamlabswater import DOMAIN as STREAMLABSWATER_DOMAIN from homeassistant.util import Throttle +from . import DOMAIN as STREAMLABSWATER_DOMAIN + DEPENDS = ["streamlabswater"] MIN_TIME_BETWEEN_LOCATION_UPDATES = timedelta(seconds=60) diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index 3af87b8a3f8..923b94a4ce2 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -3,10 +3,11 @@ from datetime import timedelta from homeassistant.components.sensor import SensorEntity -from homeassistant.components.streamlabswater import DOMAIN as STREAMLABSWATER_DOMAIN from homeassistant.const import VOLUME_GALLONS from homeassistant.util import Throttle +from . import DOMAIN as STREAMLABSWATER_DOMAIN + DEPENDENCIES = ["streamlabswater"] WATER_ICON = "mdi:water" diff --git a/homeassistant/components/supla/cover.py b/homeassistant/components/supla/cover.py index a4c2fc95792..c76b28e9de0 100644 --- a/homeassistant/components/supla/cover.py +++ b/homeassistant/components/supla/cover.py @@ -7,12 +7,8 @@ from homeassistant.components.cover import ( DEVICE_CLASS_GARAGE, CoverEntity, ) -from homeassistant.components.supla import ( - DOMAIN, - SUPLA_COORDINATORS, - SUPLA_SERVERS, - SuplaChannel, -) + +from . import DOMAIN, SUPLA_COORDINATORS, SUPLA_SERVERS, SuplaChannel _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/supla/switch.py b/homeassistant/components/supla/switch.py index 32ff208f10e..cabc934b52e 100644 --- a/homeassistant/components/supla/switch.py +++ b/homeassistant/components/supla/switch.py @@ -2,14 +2,10 @@ import logging from pprint import pformat -from homeassistant.components.supla import ( - DOMAIN, - SUPLA_COORDINATORS, - SUPLA_SERVERS, - SuplaChannel, -) from homeassistant.components.switch import SwitchEntity +from . import DOMAIN, SUPLA_COORDINATORS, SUPLA_SERVERS, SuplaChannel + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/template/binary_sensor.py b/homeassistant/components/template/binary_sensor.py index 06af6dca925..c3557ba21f4 100644 --- a/homeassistant/components/template/binary_sensor.py +++ b/homeassistant/components/template/binary_sensor.py @@ -15,7 +15,6 @@ from homeassistant.components.binary_sensor import ( PLATFORM_SCHEMA, BinarySensorEntity, ) -from homeassistant.components.template import TriggerUpdateCoordinator from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, @@ -39,6 +38,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import async_generate_entity_id from homeassistant.helpers.event import async_call_later +from . import TriggerUpdateCoordinator from .const import ( CONF_ATTRIBUTES, CONF_AVAILABILITY, diff --git a/homeassistant/components/template/number.py b/homeassistant/components/template/number.py index 90a944a2d33..da2272c3138 100644 --- a/homeassistant/components/template/number.py +++ b/homeassistant/components/template/number.py @@ -17,7 +17,6 @@ from homeassistant.components.number.const import ( DEFAULT_MIN_VALUE, DOMAIN as NUMBER_DOMAIN, ) -from homeassistant.components.template import TriggerUpdateCoordinator from homeassistant.const import ( CONF_ICON, CONF_NAME, @@ -31,6 +30,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.script import Script from homeassistant.helpers.template import Template, TemplateError +from . import TriggerUpdateCoordinator from .const import CONF_AVAILABILITY, DOMAIN from .template_entity import TemplateEntity from .trigger_entity import TriggerEntity diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index 98eb377dab3..209ff9980c9 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -26,7 +26,6 @@ from aiounifi.events import ( from aiounifi.websocket import STATE_DISCONNECTED, STATE_RUNNING import async_timeout -from homeassistant.components.unifi.switch import BLOCK_SWITCH, POE_SWITCH from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -70,6 +69,7 @@ from .const import ( UNIFI_WIRELESS_CLIENTS, ) from .errors import AuthenticationRequired, CannotConnect +from .switch import BLOCK_SWITCH, POE_SWITCH RETRY_TIMER = 15 CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1) diff --git a/homeassistant/components/wallbox/sensor.py b/homeassistant/components/wallbox/sensor.py index 835a8c405da..dd45c237c45 100644 --- a/homeassistant/components/wallbox/sensor.py +++ b/homeassistant/components/wallbox/sensor.py @@ -11,7 +11,6 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, ) -from homeassistant.components.wallbox import WallboxCoordinator from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_BATTERY, @@ -29,6 +28,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import CoordinatorEntity +from . import WallboxCoordinator from .const import ( CONF_ADDED_ENERGY_KEY, CONF_ADDED_RANGE_KEY, diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index 36480e90f12..60768b6857f 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -24,14 +24,6 @@ from homeassistant.components.media_player.const import ( SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP, ) -from homeassistant.components.webostv.const import ( - ATTR_PAYLOAD, - ATTR_SOUND_OUTPUT, - CONF_ON_ACTION, - CONF_SOURCES, - DOMAIN, - LIVE_TV_APP_ID, -) from homeassistant.const import ( ATTR_ENTITY_ID, CONF_CUSTOMIZE, @@ -45,6 +37,15 @@ from homeassistant.const import ( from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.script import Script +from .const import ( + ATTR_PAYLOAD, + ATTR_SOUND_OUTPUT, + CONF_ON_ACTION, + CONF_SOURCES, + DOMAIN, + LIVE_TV_APP_ID, +) + _LOGGER = logging.getLogger(__name__) SUPPORT_WEBOSTV = ( diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index a4abbd30dff..aa38f8c8e3e 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -10,7 +10,6 @@ import voluptuous as vol from homeassistant.auth.permissions.const import CAT_ENTITIES, POLICY_READ from homeassistant.bootstrap import SIGNAL_BOOTSTRAP_INTEGRATONS -from homeassistant.components.websocket_api.const import ERR_NOT_FOUND from homeassistant.const import EVENT_STATE_CHANGED, EVENT_TIME_CHANGED, MATCH_ALL from homeassistant.core import Context, Event, HomeAssistant, callback from homeassistant.exceptions import ( @@ -33,6 +32,7 @@ from homeassistant.setup import DATA_SETUP_TIME, async_get_loaded_integrations from . import const, decorators, messages from .connection import ActiveConnection +from .const import ERR_NOT_FOUND @callback diff --git a/homeassistant/components/withings/config_flow.py b/homeassistant/components/withings/config_flow.py index 29c1e162ed4..b447973af97 100644 --- a/homeassistant/components/withings/config_flow.py +++ b/homeassistant/components/withings/config_flow.py @@ -6,11 +6,12 @@ import logging import voluptuous as vol from withings_api.common import AuthScope -from homeassistant.components.withings import const from homeassistant.config_entries import SOURCE_REAUTH from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.util import slugify +from . import const + class WithingsFlowHandler( config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=const.DOMAIN diff --git a/homeassistant/components/yamaha_musiccast/number.py b/homeassistant/components/yamaha_musiccast/number.py index daef8bacd12..2648359f768 100644 --- a/homeassistant/components/yamaha_musiccast/number.py +++ b/homeassistant/components/yamaha_musiccast/number.py @@ -3,15 +3,12 @@ from aiomusiccast.capabilities import NumberSetter from homeassistant.components.number import NumberEntity -from homeassistant.components.yamaha_musiccast import ( - DOMAIN, - MusicCastCapabilityEntity, - MusicCastDataUpdateCoordinator, -) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import DOMAIN, MusicCastCapabilityEntity, MusicCastDataUpdateCoordinator + async def async_setup_entry( hass: HomeAssistant, diff --git a/homeassistant/components/yamaha_musiccast/select.py b/homeassistant/components/yamaha_musiccast/select.py index 6c808c3cced..68be67eac10 100644 --- a/homeassistant/components/yamaha_musiccast/select.py +++ b/homeassistant/components/yamaha_musiccast/select.py @@ -3,15 +3,12 @@ from aiomusiccast.capabilities import OptionSetter from homeassistant.components.select import SelectEntity -from homeassistant.components.yamaha_musiccast import ( - DOMAIN, - MusicCastCapabilityEntity, - MusicCastDataUpdateCoordinator, -) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import DOMAIN, MusicCastCapabilityEntity, MusicCastDataUpdateCoordinator + async def async_setup_entry( hass: HomeAssistant, diff --git a/homeassistant/components/youless/sensor.py b/homeassistant/components/youless/sensor.py index 355d4f83127..a1e094b8c70 100644 --- a/homeassistant/components/youless/sensor.py +++ b/homeassistant/components/youless/sensor.py @@ -9,7 +9,6 @@ from homeassistant.components.sensor import ( STATE_CLASS_TOTAL_INCREASING, SensorEntity, ) -from homeassistant.components.youless import DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_DEVICE, @@ -29,6 +28,8 @@ from homeassistant.helpers.update_coordinator import ( DataUpdateCoordinator, ) +from . import DOMAIN + async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback diff --git a/homeassistant/components/zha/alarm_control_panel.py b/homeassistant/components/zha/alarm_control_panel.py index 3e83a5cd3d1..4d4cba3599c 100644 --- a/homeassistant/components/zha/alarm_control_panel.py +++ b/homeassistant/components/zha/alarm_control_panel.py @@ -11,7 +11,6 @@ from homeassistant.components.alarm_control_panel import ( SUPPORT_ALARM_TRIGGER, AlarmControlPanelEntity, ) -from homeassistant.components.zha.core.typing import ZhaDeviceType from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, @@ -42,6 +41,7 @@ from .core.const import ( ) from .core.helpers import async_get_zha_config_value from .core.registries import ZHA_ENTITIES +from .core.typing import ZhaDeviceType from .entity import ZhaEntity STRICT_MATCH = functools.partial( diff --git a/homeassistant/components/zwave_js/climate.py b/homeassistant/components/zwave_js/climate.py index f9c94cc938d..0c779eeb78f 100644 --- a/homeassistant/components/zwave_js/climate.py +++ b/homeassistant/components/zwave_js/climate.py @@ -45,9 +45,6 @@ from homeassistant.components.climate.const import ( SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE, ) -from homeassistant.components.zwave_js.discovery_data_template import ( - DynamicCurrentTempClimateDataTemplate, -) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_TEMPERATURE, @@ -62,6 +59,7 @@ from homeassistant.helpers.temperature import convert_temperature from .const import DATA_CLIENT, DOMAIN from .discovery import ZwaveDiscoveryInfo +from .discovery_data_template import DynamicCurrentTempClimateDataTemplate from .entity import ZWaveBaseEntity from .helpers import get_value_of_zwave_value diff --git a/homeassistant/components/zwave_js/sensor.py b/homeassistant/components/zwave_js/sensor.py index 549df9f6264..86901b94d3d 100644 --- a/homeassistant/components/zwave_js/sensor.py +++ b/homeassistant/components/zwave_js/sensor.py @@ -24,9 +24,6 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, ) -from homeassistant.components.zwave_js.discovery_data_template import ( - NumericSensorDataTemplateData, -) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_BATTERY, @@ -75,6 +72,7 @@ from .const import ( SERVICE_RESET_METER, ) from .discovery import ZwaveDiscoveryInfo +from .discovery_data_template import NumericSensorDataTemplateData from .entity import ZWaveBaseEntity from .helpers import get_device_id