From 6b28af82828baf5e22c1d7bc51347143b5619d04 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 28 May 2025 14:04:35 +0200 Subject: [PATCH] Remove unnecessary DOMAIN alias in components (#145791) --- homeassistant/components/agent_dvr/camera.py | 4 ++-- homeassistant/components/axis/hub/hub.py | 4 ++-- homeassistant/components/deconz/logbook.py | 6 +++--- homeassistant/components/group/sensor.py | 10 +++++----- homeassistant/components/nuki/lock.py | 4 ++-- homeassistant/components/switch/light.py | 8 ++++---- homeassistant/components/switch_as_x/entity.py | 6 +++--- homeassistant/components/unifi/hub/hub.py | 4 ++-- homeassistant/components/unifi/switch.py | 8 +++----- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/agent_dvr/camera.py b/homeassistant/components/agent_dvr/camera.py index 3de7f095b13..c0076024fe4 100644 --- a/homeassistant/components/agent_dvr/camera.py +++ b/homeassistant/components/agent_dvr/camera.py @@ -15,7 +15,7 @@ from homeassistant.helpers.entity_platform import ( ) from . import AgentDVRConfigEntry -from .const import ATTRIBUTION, CAMERA_SCAN_INTERVAL_SECS, DOMAIN as AGENT_DOMAIN +from .const import ATTRIBUTION, CAMERA_SCAN_INTERVAL_SECS, DOMAIN SCAN_INTERVAL = timedelta(seconds=CAMERA_SCAN_INTERVAL_SECS) @@ -82,7 +82,7 @@ class AgentCamera(MjpegCamera): still_image_url=f"{device.client._server_url}{device.still_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}", # noqa: SLF001 ) self._attr_device_info = DeviceInfo( - identifiers={(AGENT_DOMAIN, self.unique_id)}, + identifiers={(DOMAIN, self.unique_id)}, manufacturer="Agent", model="Camera", name=f"{device.client.name} {device.name}", diff --git a/homeassistant/components/axis/hub/hub.py b/homeassistant/components/axis/hub/hub.py index 9dd4280f833..6caa8fd6871 100644 --- a/homeassistant/components/axis/hub/hub.py +++ b/homeassistant/components/axis/hub/hub.py @@ -11,7 +11,7 @@ from homeassistant.helpers import device_registry as dr from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac from homeassistant.helpers.dispatcher import async_dispatcher_send -from ..const import ATTR_MANUFACTURER, DOMAIN as AXIS_DOMAIN +from ..const import ATTR_MANUFACTURER, DOMAIN from .config import AxisConfig from .entity_loader import AxisEntityLoader from .event_source import AxisEventSource @@ -79,7 +79,7 @@ class AxisHub: config_entry_id=self.config.entry.entry_id, configuration_url=self.api.config.url, connections={(CONNECTION_NETWORK_MAC, self.unique_id)}, - identifiers={(AXIS_DOMAIN, self.unique_id)}, + identifiers={(DOMAIN, self.unique_id)}, manufacturer=ATTR_MANUFACTURER, model=f"{self.config.model} {self.product_type}", name=self.config.name, diff --git a/homeassistant/components/deconz/logbook.py b/homeassistant/components/deconz/logbook.py index 28dfb603d8b..b62e4957c4c 100644 --- a/homeassistant/components/deconz/logbook.py +++ b/homeassistant/components/deconz/logbook.py @@ -9,7 +9,7 @@ from homeassistant.const import ATTR_DEVICE_ID, CONF_EVENT, CONF_ID from homeassistant.core import Event, HomeAssistant, callback from homeassistant.helpers import device_registry as dr -from .const import CONF_GESTURE, DOMAIN as DECONZ_DOMAIN +from .const import CONF_GESTURE, DOMAIN from .deconz_event import CONF_DECONZ_ALARM_EVENT, CONF_DECONZ_EVENT from .device_trigger import ( CONF_BOTH_BUTTONS, @@ -200,6 +200,6 @@ def async_describe_events( } async_describe_event( - DECONZ_DOMAIN, CONF_DECONZ_ALARM_EVENT, async_describe_deconz_alarm_event + DOMAIN, CONF_DECONZ_ALARM_EVENT, async_describe_deconz_alarm_event ) - async_describe_event(DECONZ_DOMAIN, CONF_DECONZ_EVENT, async_describe_deconz_event) + async_describe_event(DOMAIN, CONF_DECONZ_EVENT, async_describe_deconz_event) diff --git a/homeassistant/components/group/sensor.py b/homeassistant/components/group/sensor.py index 9f0cc64ecf0..cad794fd6b9 100644 --- a/homeassistant/components/group/sensor.py +++ b/homeassistant/components/group/sensor.py @@ -55,7 +55,7 @@ from homeassistant.helpers.issue_registry import ( ) from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType -from .const import CONF_IGNORE_NON_NUMERIC, DOMAIN as GROUP_DOMAIN +from .const import CONF_IGNORE_NON_NUMERIC, DOMAIN from .entity import GroupEntity DEFAULT_NAME = "Sensor Group" @@ -509,7 +509,7 @@ class SensorGroup(GroupEntity, SensorEntity): return state_classes[0] async_create_issue( self.hass, - GROUP_DOMAIN, + DOMAIN, f"{self.entity_id}_state_classes_not_matching", is_fixable=False, is_persistent=False, @@ -566,7 +566,7 @@ class SensorGroup(GroupEntity, SensorEntity): return device_classes[0] async_create_issue( self.hass, - GROUP_DOMAIN, + DOMAIN, f"{self.entity_id}_device_classes_not_matching", is_fixable=False, is_persistent=False, @@ -654,7 +654,7 @@ class SensorGroup(GroupEntity, SensorEntity): if device_class: async_create_issue( self.hass, - GROUP_DOMAIN, + DOMAIN, f"{self.entity_id}_uoms_not_matching_device_class", is_fixable=False, is_persistent=False, @@ -670,7 +670,7 @@ class SensorGroup(GroupEntity, SensorEntity): else: async_create_issue( self.hass, - GROUP_DOMAIN, + DOMAIN, f"{self.entity_id}_uoms_not_matching_no_device_class", is_fixable=False, is_persistent=False, diff --git a/homeassistant/components/nuki/lock.py b/homeassistant/components/nuki/lock.py index 3cc972d3555..95c01eac730 100644 --- a/homeassistant/components/nuki/lock.py +++ b/homeassistant/components/nuki/lock.py @@ -18,7 +18,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import NukiEntryData -from .const import ATTR_ENABLE, ATTR_UNLATCH, DOMAIN as NUKI_DOMAIN, ERROR_STATES +from .const import ATTR_ENABLE, ATTR_UNLATCH, DOMAIN, ERROR_STATES from .entity import NukiEntity from .helpers import CannotConnect @@ -29,7 +29,7 @@ async def async_setup_entry( async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up the Nuki lock platform.""" - entry_data: NukiEntryData = hass.data[NUKI_DOMAIN][entry.entry_id] + entry_data: NukiEntryData = hass.data[DOMAIN][entry.entry_id] coordinator = entry_data.coordinator entities: list[NukiDeviceEntity] = [ diff --git a/homeassistant/components/switch/light.py b/homeassistant/components/switch/light.py index 276496ce614..a781f29bdfa 100644 --- a/homeassistant/components/switch/light.py +++ b/homeassistant/components/switch/light.py @@ -26,14 +26,14 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from .const import DOMAIN as SWITCH_DOMAIN +from .const import DOMAIN DEFAULT_NAME = "Light Switch" PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend( { vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Required(CONF_ENTITY_ID): cv.entity_domain(SWITCH_DOMAIN), + vol.Required(CONF_ENTITY_ID): cv.entity_domain(DOMAIN), } ) @@ -76,7 +76,7 @@ class LightSwitch(LightEntity): async def async_turn_on(self, **kwargs: Any) -> None: """Forward the turn_on command to the switch in this light switch.""" await self.hass.services.async_call( - SWITCH_DOMAIN, + DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: self._switch_entity_id}, blocking=True, @@ -86,7 +86,7 @@ class LightSwitch(LightEntity): async def async_turn_off(self, **kwargs: Any) -> None: """Forward the turn_off command to the switch in this light switch.""" await self.hass.services.async_call( - SWITCH_DOMAIN, + DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: self._switch_entity_id}, blocking=True, diff --git a/homeassistant/components/switch_as_x/entity.py b/homeassistant/components/switch_as_x/entity.py index 020d92e21ac..64bfe712086 100644 --- a/homeassistant/components/switch_as_x/entity.py +++ b/homeassistant/components/switch_as_x/entity.py @@ -19,7 +19,7 @@ from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity import Entity, ToggleEntity from homeassistant.helpers.event import async_track_state_change_event -from .const import DOMAIN as SWITCH_AS_X_DOMAIN +from .const import DOMAIN class BaseEntity(Entity): @@ -61,7 +61,7 @@ class BaseEntity(Entity): self._switch_entity_id = switch_entity_id self._is_new_entity = ( - registry.async_get_entity_id(domain, SWITCH_AS_X_DOMAIN, unique_id) is None + registry.async_get_entity_id(domain, DOMAIN, unique_id) is None ) @callback @@ -102,7 +102,7 @@ class BaseEntity(Entity): if registry.async_get(self.entity_id) is not None: registry.async_update_entity_options( self.entity_id, - SWITCH_AS_X_DOMAIN, + DOMAIN, self.async_generate_entity_options(), ) diff --git a/homeassistant/components/unifi/hub/hub.py b/homeassistant/components/unifi/hub/hub.py index c7615714764..f2ed95a0c79 100644 --- a/homeassistant/components/unifi/hub/hub.py +++ b/homeassistant/components/unifi/hub/hub.py @@ -16,7 +16,7 @@ from homeassistant.helpers.device_registry import ( ) from homeassistant.helpers.dispatcher import async_dispatcher_send -from ..const import ATTR_MANUFACTURER, CONF_SITE_ID, DOMAIN as UNIFI_DOMAIN, PLATFORMS +from ..const import ATTR_MANUFACTURER, CONF_SITE_ID, DOMAIN, PLATFORMS from .config import UnifiConfig from .entity_helper import UnifiEntityHelper from .entity_loader import UnifiEntityLoader @@ -104,7 +104,7 @@ class UnifiHub: return DeviceInfo( entry_type=DeviceEntryType.SERVICE, - identifiers={(UNIFI_DOMAIN, self.config.entry.unique_id)}, + identifiers={(DOMAIN, self.config.entry.unique_id)}, manufacturer=ATTR_MANUFACTURER, model="UniFi Network Application", name="UniFi Network", diff --git a/homeassistant/components/unifi/switch.py b/homeassistant/components/unifi/switch.py index 282d0c9ae93..95c7736e0d7 100644 --- a/homeassistant/components/unifi/switch.py +++ b/homeassistant/components/unifi/switch.py @@ -52,7 +52,7 @@ from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import UnifiConfigEntry -from .const import ATTR_MANUFACTURER, DOMAIN as UNIFI_DOMAIN +from .const import ATTR_MANUFACTURER, DOMAIN from .entity import ( HandlerT, SubscriptionT, @@ -367,14 +367,12 @@ def async_update_unique_id(hass: HomeAssistant, config_entry: UnifiConfigEntry) def update_unique_id(obj_id: str, type_name: str) -> None: """Rework unique ID.""" new_unique_id = f"{type_name}-{obj_id}" - if ent_reg.async_get_entity_id(SWITCH_DOMAIN, UNIFI_DOMAIN, new_unique_id): + if ent_reg.async_get_entity_id(SWITCH_DOMAIN, DOMAIN, new_unique_id): return prefix, _, suffix = obj_id.partition("_") unique_id = f"{prefix}-{type_name}-{suffix}" - if entity_id := ent_reg.async_get_entity_id( - SWITCH_DOMAIN, UNIFI_DOMAIN, unique_id - ): + if entity_id := ent_reg.async_get_entity_id(SWITCH_DOMAIN, DOMAIN, unique_id): ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id) for obj_id in hub.api.outlets: