Drop alias from local DOMAIN import (#144867)

This commit is contained in:
epenet 2025-05-14 12:24:46 +02:00 committed by GitHub
parent 8ccedd4064
commit 161b62d8fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 55 additions and 70 deletions

View File

@ -47,7 +47,7 @@ from .const import (
CONF_VIDEO_SOURCE,
DEFAULT_STREAM_PROFILE,
DEFAULT_VIDEO_SOURCE,
DOMAIN as AXIS_DOMAIN,
DOMAIN,
)
from .errors import AuthenticationRequired, CannotConnect
from .hub import AxisHub, get_axis_api
@ -58,7 +58,7 @@ DEFAULT_PROTOCOL = "https"
PROTOCOL_CHOICES = ["https", "http"]
class AxisFlowHandler(ConfigFlow, domain=AXIS_DOMAIN):
class AxisFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Axis config flow."""
VERSION = 3
@ -146,7 +146,7 @@ class AxisFlowHandler(ConfigFlow, domain=AXIS_DOMAIN):
model = self.config[CONF_MODEL]
same_model = [
entry.data[CONF_NAME]
for entry in self.hass.config_entries.async_entries(AXIS_DOMAIN)
for entry in self.hass.config_entries.async_entries(DOMAIN)
if entry.source != SOURCE_IGNORE and entry.data[CONF_MODEL] == model
]

View File

@ -22,13 +22,7 @@ from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.ssl import get_default_context
from .const import (
CONF_GCID,
CONF_READ_ONLY,
CONF_REFRESH_TOKEN,
DOMAIN as BMW_DOMAIN,
SCAN_INTERVALS,
)
from .const import CONF_GCID, CONF_READ_ONLY, CONF_REFRESH_TOKEN, DOMAIN, SCAN_INTERVALS
_LOGGER = logging.getLogger(__name__)
@ -63,7 +57,7 @@ class BMWDataUpdateCoordinator(DataUpdateCoordinator[None]):
hass,
_LOGGER,
config_entry=config_entry,
name=f"{BMW_DOMAIN}-{config_entry.data[CONF_USERNAME]}",
name=f"{DOMAIN}-{config_entry.data[CONF_USERNAME]}",
update_interval=timedelta(
seconds=SCAN_INTERVALS[config_entry.data[CONF_REGION]]
),
@ -81,26 +75,26 @@ class BMWDataUpdateCoordinator(DataUpdateCoordinator[None]):
except MyBMWCaptchaMissingError as err:
# If a captcha is required (user/password login flow), always trigger the reauth flow
raise ConfigEntryAuthFailed(
translation_domain=BMW_DOMAIN,
translation_domain=DOMAIN,
translation_key="missing_captcha",
) from err
except MyBMWAuthError as err:
# Allow one retry interval before raising AuthFailed to avoid flaky API issues
if self.last_update_success:
raise UpdateFailed(
translation_domain=BMW_DOMAIN,
translation_domain=DOMAIN,
translation_key="update_failed",
translation_placeholders={"exception": str(err)},
) from err
# Clear refresh token and trigger reauth if previous update failed as well
self._update_config_entry_refresh_token(None)
raise ConfigEntryAuthFailed(
translation_domain=BMW_DOMAIN,
translation_domain=DOMAIN,
translation_key="invalid_auth",
) from err
except (MyBMWAPIError, RequestError) as err:
raise UpdateFailed(
translation_domain=BMW_DOMAIN,
translation_domain=DOMAIN,
translation_key="update_failed",
translation_placeholders={"exception": str(err)},
) from err

View File

@ -60,7 +60,7 @@ from .const import (
ADDED_CAST_DEVICES_KEY,
CAST_MULTIZONE_MANAGER_KEY,
CONF_IGNORE_CEC,
DOMAIN as CAST_DOMAIN,
DOMAIN,
SIGNAL_CAST_DISCOVERED,
SIGNAL_CAST_REMOVED,
SIGNAL_HASS_CAST_SHOW_VIEW,
@ -315,7 +315,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
self._cast_view_remove_handler: CALLBACK_TYPE | None = None
self._attr_unique_id = str(cast_info.uuid)
self._attr_device_info = DeviceInfo(
identifiers={(CAST_DOMAIN, str(cast_info.uuid).replace("-", ""))},
identifiers={(DOMAIN, str(cast_info.uuid).replace("-", ""))},
manufacturer=str(cast_info.cast_info.manufacturer),
model=cast_info.cast_info.model_name,
name=str(cast_info.friendly_name),
@ -591,7 +591,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
"""Generate root node."""
children = []
# Add media browsers
for platform in self.hass.data[CAST_DOMAIN]["cast_platform"].values():
for platform in self.hass.data[DOMAIN]["cast_platform"].values():
children.extend(
await platform.async_get_media_browser_root_object(
self.hass, self._chromecast.cast_type
@ -650,7 +650,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
platform: CastProtocol
assert media_content_type is not None
for platform in self.hass.data[CAST_DOMAIN]["cast_platform"].values():
for platform in self.hass.data[DOMAIN]["cast_platform"].values():
browse_media = await platform.async_browse_media(
self.hass,
media_content_type,
@ -680,7 +680,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
extra = kwargs.get(ATTR_MEDIA_EXTRA, {})
# Handle media supported by a known cast app
if media_type == CAST_DOMAIN:
if media_type == DOMAIN:
try:
app_data = json.loads(media_id)
if metadata := extra.get("metadata"):
@ -712,7 +712,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
return
# Try the cast platforms
for platform in self.hass.data[CAST_DOMAIN]["cast_platform"].values():
for platform in self.hass.data[DOMAIN]["cast_platform"].values():
result = await platform.async_play_media(
self.hass, self.entity_id, chromecast, media_type, media_id
)

View File

@ -43,7 +43,7 @@ from homeassistant.util.dt import utcnow
from .const import (
CONF_ENTITY_CONFIG,
CONF_FILTER,
DOMAIN as CLOUD_DOMAIN,
DOMAIN,
PREF_ALEXA_REPORT_STATE,
PREF_ENABLE_ALEXA,
PREF_SHOULD_EXPOSE,
@ -55,7 +55,7 @@ if TYPE_CHECKING:
_LOGGER = logging.getLogger(__name__)
CLOUD_ALEXA = f"{CLOUD_DOMAIN}.{ALEXA_DOMAIN}"
CLOUD_ALEXA = f"{DOMAIN}.{ALEXA_DOMAIN}"
# Time to wait when entity preferences have changed before syncing it to
# the cloud.

View File

@ -41,7 +41,7 @@ from .const import (
CONF_ENTITY_CONFIG,
CONF_FILTER,
DEFAULT_DISABLE_2FA,
DOMAIN as CLOUD_DOMAIN,
DOMAIN,
PREF_DISABLE_2FA,
PREF_SHOULD_EXPOSE,
)
@ -52,7 +52,7 @@ if TYPE_CHECKING:
_LOGGER = logging.getLogger(__name__)
CLOUD_GOOGLE = f"{CLOUD_DOMAIN}.{GOOGLE_DOMAIN}"
CLOUD_GOOGLE = f"{DOMAIN}.{GOOGLE_DOMAIN}"
SUPPORTED_DOMAINS = {

View File

@ -17,12 +17,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.dispatcher import async_dispatcher_send
from ..const import (
CONF_MASTER_GATEWAY,
DOMAIN as DECONZ_DOMAIN,
HASSIO_CONFIGURATION_URL,
PLATFORMS,
)
from ..const import CONF_MASTER_GATEWAY, DOMAIN, HASSIO_CONFIGURATION_URL, PLATFORMS
from .config import DeconzConfig
if TYPE_CHECKING:
@ -193,7 +188,7 @@ class DeconzHub:
config_entry_id=self.config_entry.entry_id,
configuration_url=configuration_url,
entry_type=dr.DeviceEntryType.SERVICE,
identifiers={(DECONZ_DOMAIN, self.api.config.bridge_id)},
identifiers={(DOMAIN, self.api.config.bridge_id)},
manufacturer="Dresden Elektronik",
model=self.api.config.model_id,
name=self.api.config.name,

View File

@ -45,7 +45,7 @@ from ..const import (
CONF_ALLOW_UNREACHABLE,
DEFAULT_ALLOW_HUE_GROUPS,
DEFAULT_ALLOW_UNREACHABLE,
DOMAIN as HUE_DOMAIN,
DOMAIN,
GROUP_TYPE_ENTERTAINMENT,
GROUP_TYPE_LIGHT_GROUP,
GROUP_TYPE_LIGHT_SOURCE,
@ -141,7 +141,7 @@ def create_light(item_class, coordinator, bridge, is_group, rooms, api, item_id)
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Hue lights from a config entry."""
bridge: HueBridge = hass.data[HUE_DOMAIN][config_entry.entry_id]
bridge: HueBridge = hass.data[DOMAIN][config_entry.entry_id]
api_version = tuple(int(v) for v in bridge.api.config.apiversion.split("."))
rooms = {}
@ -518,7 +518,7 @@ class HueLight(CoordinatorEntity, LightEntity):
suggested_area = self._rooms[self.light.id]
return DeviceInfo(
identifiers={(HUE_DOMAIN, self.device_id)},
identifiers={(DOMAIN, self.device_id)},
manufacturer=self.light.manufacturername,
# productname added in Hue Bridge API 1.24
# (published 03/05/2018)
@ -526,7 +526,7 @@ class HueLight(CoordinatorEntity, LightEntity):
name=self.name,
sw_version=self.light.swversion,
suggested_area=suggested_area,
via_device=(HUE_DOMAIN, self.bridge.api.config.bridgeid),
via_device=(DOMAIN, self.bridge.api.config.bridgeid),
)
async def async_turn_on(self, **kwargs):

View File

@ -3,11 +3,7 @@
from homeassistant.helpers import entity
from homeassistant.helpers.device_registry import DeviceInfo
from ..const import (
CONF_ALLOW_UNREACHABLE,
DEFAULT_ALLOW_UNREACHABLE,
DOMAIN as HUE_DOMAIN,
)
from ..const import CONF_ALLOW_UNREACHABLE, DEFAULT_ALLOW_UNREACHABLE, DOMAIN
class GenericHueDevice(entity.Entity): # pylint: disable=hass-enforce-class-module
@ -55,10 +51,10 @@ class GenericHueDevice(entity.Entity): # pylint: disable=hass-enforce-class-mod
Links individual entities together in the hass device registry.
"""
return DeviceInfo(
identifiers={(HUE_DOMAIN, self.device_id)},
identifiers={(DOMAIN, self.device_id)},
manufacturer=self.primary_sensor.manufacturername,
model=(self.primary_sensor.productname or self.primary_sensor.modelid),
name=self.primary_sensor.name,
sw_version=self.primary_sensor.swversion,
via_device=(HUE_DOMAIN, self.bridge.api.config.bridgeid),
via_device=(DOMAIN, self.bridge.api.config.bridgeid),
)

View File

@ -22,7 +22,7 @@ from .const import (
CONF_ACTIVATION,
CONF_MOMENTARY,
CONF_PAUSE,
DOMAIN as KONNECTED_DOMAIN,
DOMAIN,
STATE_HIGH,
STATE_LOW,
)
@ -36,7 +36,7 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up switches attached to a Konnected device from a config entry."""
data = hass.data[KONNECTED_DOMAIN]
data = hass.data[DOMAIN]
device_id = config_entry.data["id"]
switches = [
KonnectedSwitch(device_id, zone_data.get(CONF_ZONE), zone_data)
@ -63,12 +63,12 @@ class KonnectedSwitch(SwitchEntity):
f"{device_id}-{self._zone_num}-{self._momentary}-"
f"{self._pause}-{self._repeat}"
)
self._attr_device_info = DeviceInfo(identifiers={(KONNECTED_DOMAIN, device_id)})
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, device_id)})
@property
def panel(self):
"""Return the Konnected HTTP client."""
device_data = self.hass.data[KONNECTED_DOMAIN][CONF_DEVICES][self._device_id]
device_data = self.hass.data[DOMAIN][CONF_DEVICES][self._device_id]
return device_data.get("panel")
@property

View File

@ -34,7 +34,7 @@ from . import format_unique_id, load_games, save_games
from .const import (
ATTR_MEDIA_IMAGE_URL,
DEFAULT_ALIAS,
DOMAIN as PS4_DOMAIN,
DOMAIN,
PS4_DATA,
REGIONS as deprecated_regions,
)
@ -366,7 +366,7 @@ class PS4Device(MediaPlayerEntity):
_sw_version = _sw_version[1:4]
sw_version = f"{_sw_version[0]}.{_sw_version[1:]}"
self._attr_device_info = DeviceInfo(
identifiers={(PS4_DOMAIN, status["host-id"])},
identifiers={(DOMAIN, status["host-id"])},
manufacturer="Sony Interactive Entertainment Inc.",
model="PlayStation 4",
name=status["host-name"],

View File

@ -15,7 +15,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .const import (
DOMAIN as DOMAIN_RACHIO,
DOMAIN,
KEY_BATTERY_STATUS,
KEY_DEVICE_ID,
KEY_LOW,
@ -55,7 +55,7 @@ async def async_setup_entry(
def _create_entities(hass: HomeAssistant, config_entry: ConfigEntry) -> list[Entity]:
entities: list[Entity] = []
person: RachioPerson = hass.data[DOMAIN_RACHIO][config_entry.entry_id]
person: RachioPerson = hass.data[DOMAIN][config_entry.entry_id]
for controller in person.controllers:
entities.append(RachioControllerOnlineBinarySensor(controller))
entities.append(RachioRainSensor(controller))

View File

@ -17,7 +17,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util
from .const import (
DOMAIN as DOMAIN_RACHIO,
DOMAIN,
KEY_ADDRESS,
KEY_DURATION_SECONDS,
KEY_ID,
@ -44,7 +44,7 @@ async def async_setup_entry(
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up entry for Rachio smart hose timer calendar."""
person: RachioPerson = hass.data[DOMAIN_RACHIO][config_entry.entry_id]
person: RachioPerson = hass.data[DOMAIN][config_entry.entry_id]
async_add_entities(
RachioCalendarEntity(base_station.schedule_coordinator, base_station)
for base_station in person.base_stations

View File

@ -23,7 +23,7 @@ from homeassistant.util.dt import as_timestamp, now, parse_datetime, utc_from_ti
from .const import (
CONF_MANUAL_RUN_MINS,
DEFAULT_MANUAL_RUN_MINS,
DOMAIN as DOMAIN_RACHIO,
DOMAIN,
KEY_CURRENT_STATUS,
KEY_CUSTOM_CROP,
KEY_CUSTOM_SHADE,
@ -119,7 +119,7 @@ async def async_setup_entry(
def start_multiple(service: ServiceCall) -> None:
"""Service to start multiple zones in sequence."""
zones_list = []
person = hass.data[DOMAIN_RACHIO][config_entry.entry_id]
person = hass.data[DOMAIN][config_entry.entry_id]
entity_id = service.data[ATTR_ENTITY_ID]
duration = iter(service.data[ATTR_DURATION])
default_time = service.data[ATTR_DURATION][0]
@ -160,7 +160,7 @@ async def async_setup_entry(
return
hass.services.async_register(
DOMAIN_RACHIO,
DOMAIN,
SERVICE_START_MULTIPLE_ZONES,
start_multiple,
schema=START_MULTIPLE_ZONES_SCHEMA,
@ -177,7 +177,7 @@ async def async_setup_entry(
def _create_entities(hass: HomeAssistant, config_entry: ConfigEntry) -> list[Entity]:
entities: list[Entity] = []
person: RachioPerson = hass.data[DOMAIN_RACHIO][config_entry.entry_id]
person: RachioPerson = hass.data[DOMAIN][config_entry.entry_id]
# Fetch the schedule once at startup
# in order to avoid every zone doing it
for controller in person.controllers:

View File

@ -52,7 +52,7 @@ from homeassistant.helpers.event import async_call_later
from . import UnjoinData, media_browser
from .const import (
DATA_SONOS,
DOMAIN as SONOS_DOMAIN,
DOMAIN,
MEDIA_TYPES_TO_SONOS,
MODELS_LINEIN_AND_TV,
MODELS_LINEIN_ONLY,
@ -119,7 +119,7 @@ async def async_setup_entry(
_LOGGER.debug("Creating media_player on %s", speaker.zone_name)
async_add_entities([SonosMediaPlayerEntity(speaker)])
@service.verify_domain_control(hass, SONOS_DOMAIN)
@service.verify_domain_control(hass, DOMAIN)
async def async_service_handle(service_call: ServiceCall) -> None:
"""Handle dispatched services."""
assert platform is not None
@ -151,11 +151,11 @@ async def async_setup_entry(
)
hass.services.async_register(
SONOS_DOMAIN, SERVICE_SNAPSHOT, async_service_handle, join_unjoin_schema
DOMAIN, SERVICE_SNAPSHOT, async_service_handle, join_unjoin_schema
)
hass.services.async_register(
SONOS_DOMAIN, SERVICE_RESTORE, async_service_handle, join_unjoin_schema
DOMAIN, SERVICE_RESTORE, async_service_handle, join_unjoin_schema
)
platform.async_register_entity_service(
@ -448,7 +448,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
if len(fav) != 1:
raise ServiceValidationError(
translation_domain=SONOS_DOMAIN,
translation_domain=DOMAIN,
translation_key="invalid_favorite",
translation_placeholders={
"name": name,
@ -577,7 +577,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
)
else:
raise HomeAssistantError(
translation_domain=SONOS_DOMAIN,
translation_domain=DOMAIN,
translation_key="announce_media_error",
translation_placeholders={
"media_id": media_id,
@ -684,7 +684,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
playlist = next((p for p in playlists if p.title == media_id), None)
if not playlist:
raise ServiceValidationError(
translation_domain=SONOS_DOMAIN,
translation_domain=DOMAIN,
translation_key="invalid_sonos_playlist",
translation_placeholders={
"name": media_id,
@ -697,7 +697,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
item = media_browser.get_media(self.media.library, media_id, media_type)
if not item:
raise ServiceValidationError(
translation_domain=SONOS_DOMAIN,
translation_domain=DOMAIN,
translation_key="invalid_media",
translation_placeholders={
"media_id": media_id,
@ -706,7 +706,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
self._play_media_queue(soco, item, enqueue)
else:
raise ServiceValidationError(
translation_domain=SONOS_DOMAIN,
translation_domain=DOMAIN,
translation_key="invalid_content_type",
translation_placeholders={
"media_type": media_type,

View File

@ -20,7 +20,7 @@ from homeassistant.helpers.event import async_track_time_change
from .const import (
DATA_SONOS,
DOMAIN as SONOS_DOMAIN,
DOMAIN,
SONOS_ALARMS_UPDATED,
SONOS_CREATE_ALARM,
SONOS_CREATE_SWITCHES,
@ -276,7 +276,7 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
new_device = device_registry.async_get_or_create(
config_entry_id=cast(str, entity.config_entry_id),
identifiers={(SONOS_DOMAIN, self.soco.uid)},
identifiers={(DOMAIN, self.soco.uid)},
connections={(dr.CONNECTION_NETWORK_MAC, self.speaker.mac_address)},
)
if (

View File

@ -56,7 +56,7 @@ from .const import (
CONF_TRACK_DEVICES,
CONF_TRACK_WIRED_CLIENTS,
DEFAULT_DPI_RESTRICTIONS,
DOMAIN as UNIFI_DOMAIN,
DOMAIN,
)
from .errors import AuthenticationRequired, CannotConnect
from .hub import UnifiHub, get_unifi_api
@ -72,7 +72,7 @@ MODEL_PORTS = {
}
class UnifiFlowHandler(ConfigFlow, domain=UNIFI_DOMAIN):
class UnifiFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a UniFi Network config flow."""
VERSION = 1