From e750f8f457a9ac89b1eb125ab2b927d81393bd69 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:32:33 +0200 Subject: [PATCH] Add alias to DOMAIN import (part 4) (#125563) * Add alias to DOMAIN import (part 4) * Simplify * More integration * Apply suggestions from code review Co-authored-by: G Johansson * Revert "Apply suggestions from code review" This reverts commit 07471d3629bd83ddfc2e254fc4cda3053461570d. --------- Co-authored-by: G Johansson --- homeassistant/components/flux/switch.py | 4 ++-- homeassistant/components/heos/media_player.py | 4 ++-- homeassistant/components/iaqualink/binary_sensor.py | 7 +++++-- homeassistant/components/iaqualink/light.py | 5 +++-- homeassistant/components/iaqualink/sensor.py | 9 +++++++-- homeassistant/components/iaqualink/switch.py | 5 +++-- homeassistant/components/lutron_caseta/cover.py | 4 ++-- homeassistant/components/lutron_caseta/fan.py | 8 ++++++-- homeassistant/components/lutron_caseta/light.py | 4 ++-- homeassistant/components/lutron_caseta/switch.py | 4 ++-- homeassistant/components/mystrom/binary_sensor.py | 7 +++++-- .../components/point/alarm_control_panel.py | 6 ++++-- homeassistant/components/point/binary_sensor.py | 6 ++++-- homeassistant/components/point/sensor.py | 6 ++++-- homeassistant/components/push/camera.py | 4 ++-- .../components/screenlogic/binary_sensor.py | 10 +++++++--- homeassistant/components/screenlogic/number.py | 6 +++--- homeassistant/components/screenlogic/sensor.py | 6 +++--- homeassistant/components/unifi/switch.py | 12 +++++++----- homeassistant/components/universal/media_player.py | 12 +++++++++--- 20 files changed, 82 insertions(+), 47 deletions(-) diff --git a/homeassistant/components/flux/switch.py b/homeassistant/components/flux/switch.py index fac31d445cc..8a3d7ec7260 100644 --- a/homeassistant/components/flux/switch.py +++ b/homeassistant/components/flux/switch.py @@ -21,7 +21,7 @@ from homeassistant.components.light import ( VALID_TRANSITION, is_on, ) -from homeassistant.components.switch import DOMAIN, SwitchEntity +from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity from homeassistant.const import ( ATTR_ENTITY_ID, CONF_BRIGHTNESS, @@ -178,7 +178,7 @@ async def async_setup_platform( await flux.async_flux_update() service_name = slugify(f"{name} update") - hass.services.async_register(DOMAIN, service_name, async_update) + hass.services.async_register(SWITCH_DOMAIN, service_name, async_update) class FluxSwitch(SwitchEntity, RestoreEntity): diff --git a/homeassistant/components/heos/media_player.py b/homeassistant/components/heos/media_player.py index 858ebd225b7..0f9f7facd33 100644 --- a/homeassistant/components/heos/media_player.py +++ b/homeassistant/components/heos/media_player.py @@ -13,7 +13,7 @@ from pyheos import HeosError, const as heos_const from homeassistant.components import media_source from homeassistant.components.media_player import ( ATTR_MEDIA_ENQUEUE, - DOMAIN, + DOMAIN as MEDIA_PLAYER_DOMAIN, BrowseMedia, MediaPlayerEnqueue, MediaPlayerEntity, @@ -83,7 +83,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Add media players for a config entry.""" - players = hass.data[HEOS_DOMAIN][DOMAIN] + players = hass.data[HEOS_DOMAIN][MEDIA_PLAYER_DOMAIN] devices = [HeosMediaPlayer(player) for player in players.values()] async_add_entities(devices, True) diff --git a/homeassistant/components/iaqualink/binary_sensor.py b/homeassistant/components/iaqualink/binary_sensor.py index 06dbcf18e4a..92e152701a4 100644 --- a/homeassistant/components/iaqualink/binary_sensor.py +++ b/homeassistant/components/iaqualink/binary_sensor.py @@ -5,7 +5,7 @@ from __future__ import annotations from iaqualink.device import AqualinkBinarySensor from homeassistant.components.binary_sensor import ( - DOMAIN, + DOMAIN as BINARY_SENSOR_DOMAIN, BinarySensorDeviceClass, BinarySensorEntity, ) @@ -26,7 +26,10 @@ async def async_setup_entry( ) -> None: """Set up discovered binary sensors.""" async_add_entities( - (HassAqualinkBinarySensor(dev) for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]), + ( + HassAqualinkBinarySensor(dev) + for dev in hass.data[AQUALINK_DOMAIN][BINARY_SENSOR_DOMAIN] + ), True, ) diff --git a/homeassistant/components/iaqualink/light.py b/homeassistant/components/iaqualink/light.py index bce4f2c9855..74ffe489a51 100644 --- a/homeassistant/components/iaqualink/light.py +++ b/homeassistant/components/iaqualink/light.py @@ -9,7 +9,7 @@ from iaqualink.device import AqualinkLight from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_EFFECT, - DOMAIN, + DOMAIN as LIGHT_DOMAIN, ColorMode, LightEntity, LightEntityFeature, @@ -32,7 +32,8 @@ async def async_setup_entry( ) -> None: """Set up discovered lights.""" async_add_entities( - (HassAqualinkLight(dev) for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]), True + (HassAqualinkLight(dev) for dev in hass.data[AQUALINK_DOMAIN][LIGHT_DOMAIN]), + True, ) diff --git a/homeassistant/components/iaqualink/sensor.py b/homeassistant/components/iaqualink/sensor.py index 8e3983e9c91..35dc01928ec 100644 --- a/homeassistant/components/iaqualink/sensor.py +++ b/homeassistant/components/iaqualink/sensor.py @@ -4,7 +4,11 @@ from __future__ import annotations from iaqualink.device import AqualinkSensor -from homeassistant.components.sensor import DOMAIN, SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import ( + DOMAIN as SENSOR_DOMAIN, + SensorDeviceClass, + SensorEntity, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant @@ -23,7 +27,8 @@ async def async_setup_entry( ) -> None: """Set up discovered sensors.""" async_add_entities( - (HassAqualinkSensor(dev) for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]), True + (HassAqualinkSensor(dev) for dev in hass.data[AQUALINK_DOMAIN][SENSOR_DOMAIN]), + True, ) diff --git a/homeassistant/components/iaqualink/switch.py b/homeassistant/components/iaqualink/switch.py index e681879855b..43b35b456a3 100644 --- a/homeassistant/components/iaqualink/switch.py +++ b/homeassistant/components/iaqualink/switch.py @@ -6,7 +6,7 @@ from typing import Any from iaqualink.device import AqualinkSwitch -from homeassistant.components.switch import DOMAIN, SwitchEntity +from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -25,7 +25,8 @@ async def async_setup_entry( ) -> None: """Set up discovered switches.""" async_add_entities( - (HassAqualinkSwitch(dev) for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]), True + (HassAqualinkSwitch(dev) for dev in hass.data[AQUALINK_DOMAIN][SWITCH_DOMAIN]), + True, ) diff --git a/homeassistant/components/lutron_caseta/cover.py b/homeassistant/components/lutron_caseta/cover.py index 3edb62c0d98..47711abb80e 100644 --- a/homeassistant/components/lutron_caseta/cover.py +++ b/homeassistant/components/lutron_caseta/cover.py @@ -5,7 +5,7 @@ from typing import Any from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, - DOMAIN, + DOMAIN as COVER_DOMAIN, CoverDeviceClass, CoverEntity, CoverEntityFeature, @@ -122,7 +122,7 @@ async def async_setup_entry( """ data = config_entry.runtime_data bridge = data.bridge - cover_devices = bridge.get_devices_by_domain(DOMAIN) + cover_devices = bridge.get_devices_by_domain(COVER_DOMAIN) async_add_entities( # default to standard LutronCasetaCover type if the pylutron type is not yet mapped PYLUTRON_TYPE_TO_CLASSES.get(cover_device["type"], LutronCasetaShade)( diff --git a/homeassistant/components/lutron_caseta/fan.py b/homeassistant/components/lutron_caseta/fan.py index 1e7c0b2265c..f15f6d53e15 100644 --- a/homeassistant/components/lutron_caseta/fan.py +++ b/homeassistant/components/lutron_caseta/fan.py @@ -6,7 +6,11 @@ from typing import Any from pylutron_caseta import FAN_HIGH, FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_OFF -from homeassistant.components.fan import DOMAIN, FanEntity, FanEntityFeature +from homeassistant.components.fan import ( + DOMAIN as FAN_DOMAIN, + FanEntity, + FanEntityFeature, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util.percentage import ( @@ -33,7 +37,7 @@ async def async_setup_entry( """ data = config_entry.runtime_data bridge = data.bridge - fan_devices = bridge.get_devices_by_domain(DOMAIN) + fan_devices = bridge.get_devices_by_domain(FAN_DOMAIN) async_add_entities(LutronCasetaFan(fan_device, data) for fan_device in fan_devices) diff --git a/homeassistant/components/lutron_caseta/light.py b/homeassistant/components/lutron_caseta/light.py index c0cf9449f87..7eed03a1e06 100644 --- a/homeassistant/components/lutron_caseta/light.py +++ b/homeassistant/components/lutron_caseta/light.py @@ -15,7 +15,7 @@ from homeassistant.components.light import ( ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_WHITE, - DOMAIN, + DOMAIN as LIGHT_DOMAIN, ColorMode, LightEntity, LightEntityFeature, @@ -62,7 +62,7 @@ async def async_setup_entry( """ data = config_entry.runtime_data bridge = data.bridge - light_devices = bridge.get_devices_by_domain(DOMAIN) + light_devices = bridge.get_devices_by_domain(LIGHT_DOMAIN) async_add_entities( LutronCasetaLight(light_device, data) for light_device in light_devices ) diff --git a/homeassistant/components/lutron_caseta/switch.py b/homeassistant/components/lutron_caseta/switch.py index b7ec5b58b04..b8543309fbf 100644 --- a/homeassistant/components/lutron_caseta/switch.py +++ b/homeassistant/components/lutron_caseta/switch.py @@ -2,7 +2,7 @@ from typing import Any -from homeassistant.components.switch import DOMAIN, SwitchEntity +from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -22,7 +22,7 @@ async def async_setup_entry( """ data = config_entry.runtime_data bridge = data.bridge - switch_devices = bridge.get_devices_by_domain(DOMAIN) + switch_devices = bridge.get_devices_by_domain(SWITCH_DOMAIN) async_add_entities( LutronCasetaLight(switch_device, data) for switch_device in switch_devices ) diff --git a/homeassistant/components/mystrom/binary_sensor.py b/homeassistant/components/mystrom/binary_sensor.py index 17a1da75a96..c63ab4e5f3b 100644 --- a/homeassistant/components/mystrom/binary_sensor.py +++ b/homeassistant/components/mystrom/binary_sensor.py @@ -5,7 +5,10 @@ from __future__ import annotations from http import HTTPStatus import logging -from homeassistant.components.binary_sensor import DOMAIN, BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DOMAIN as BINARY_SENSOR_DOMAIN, + BinarySensorEntity, +) from homeassistant.components.http import KEY_HASS, HomeAssistantView from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -55,7 +58,7 @@ class MyStromView(HomeAssistantView): ) button_id = data[button_action] - entity_id = f"{DOMAIN}.{button_id}_{button_action}" + entity_id = f"{BINARY_SENSOR_DOMAIN}.{button_id}_{button_action}" if entity_id not in self.buttons: _LOGGER.info( "New myStrom button/action detected: %s/%s", button_id, button_action diff --git a/homeassistant/components/point/alarm_control_panel.py b/homeassistant/components/point/alarm_control_panel.py index 844d1eba553..70c19056397 100644 --- a/homeassistant/components/point/alarm_control_panel.py +++ b/homeassistant/components/point/alarm_control_panel.py @@ -6,7 +6,7 @@ from collections.abc import Callable import logging from homeassistant.components.alarm_control_panel import ( - DOMAIN, + DOMAIN as ALARM_CONTROL_PANEL_DOMAIN, AlarmControlPanelEntity, AlarmControlPanelEntityFeature, ) @@ -47,7 +47,9 @@ async def async_setup_entry( async_add_entities([MinutPointAlarmControl(client, home_id)], True) async_dispatcher_connect( - hass, POINT_DISCOVERY_NEW.format(DOMAIN, POINT_DOMAIN), async_discover_home + hass, + POINT_DISCOVERY_NEW.format(ALARM_CONTROL_PANEL_DOMAIN, POINT_DOMAIN), + async_discover_home, ) diff --git a/homeassistant/components/point/binary_sensor.py b/homeassistant/components/point/binary_sensor.py index 7a698925db6..db3a7328e00 100644 --- a/homeassistant/components/point/binary_sensor.py +++ b/homeassistant/components/point/binary_sensor.py @@ -7,7 +7,7 @@ import logging from pypoint import EVENTS from homeassistant.components.binary_sensor import ( - DOMAIN, + DOMAIN as BINARY_SENSOR_DOMAIN, BinarySensorDeviceClass, BinarySensorEntity, ) @@ -60,7 +60,9 @@ async def async_setup_entry( ) async_dispatcher_connect( - hass, POINT_DISCOVERY_NEW.format(DOMAIN, POINT_DOMAIN), async_discover_sensor + hass, + POINT_DISCOVERY_NEW.format(BINARY_SENSOR_DOMAIN, POINT_DOMAIN), + async_discover_sensor, ) diff --git a/homeassistant/components/point/sensor.py b/homeassistant/components/point/sensor.py index f648bb4daf9..446a67273fc 100644 --- a/homeassistant/components/point/sensor.py +++ b/homeassistant/components/point/sensor.py @@ -5,7 +5,7 @@ from __future__ import annotations import logging from homeassistant.components.sensor import ( - DOMAIN, + DOMAIN as SENSOR_DOMAIN, SensorDeviceClass, SensorEntity, SensorEntityDescription, @@ -64,7 +64,9 @@ async def async_setup_entry( ) async_dispatcher_connect( - hass, POINT_DISCOVERY_NEW.format(DOMAIN, POINT_DOMAIN), async_discover_sensor + hass, + POINT_DISCOVERY_NEW.format(SENSOR_DOMAIN, POINT_DOMAIN), + async_discover_sensor, ) diff --git a/homeassistant/components/push/camera.py b/homeassistant/components/push/camera.py index eb51ba49aa2..6e75cbec420 100644 --- a/homeassistant/components/push/camera.py +++ b/homeassistant/components/push/camera.py @@ -13,7 +13,7 @@ import voluptuous as vol from homeassistant.components import webhook from homeassistant.components.camera import ( - DOMAIN, + DOMAIN as CAMERA_DOMAIN, PLATFORM_SCHEMA as CAMERA_PLATFORM_SCHEMA, STATE_IDLE, Camera, @@ -121,7 +121,7 @@ class PushCamera(Camera): try: webhook.async_register( - self.hass, DOMAIN, self.name, self.webhook_id, handle_webhook + self.hass, CAMERA_DOMAIN, self.name, self.webhook_id, handle_webhook ) except ValueError: _LOGGER.error( diff --git a/homeassistant/components/screenlogic/binary_sensor.py b/homeassistant/components/screenlogic/binary_sensor.py index 13582b81196..fda1c348edf 100644 --- a/homeassistant/components/screenlogic/binary_sensor.py +++ b/homeassistant/components/screenlogic/binary_sensor.py @@ -9,7 +9,7 @@ from screenlogicpy.const.msg import CODE from screenlogicpy.device_const.system import EQUIPMENT_FLAG from homeassistant.components.binary_sensor import ( - DOMAIN, + DOMAIN as BINARY_SENSOR_DOMAIN, BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, @@ -202,7 +202,9 @@ async def async_setup_entry( chem_sensor_description.key, ) if EQUIPMENT_FLAG.INTELLICHEM not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, chem_sensor_data_path) + cleanup_excluded_entity( + coordinator, BINARY_SENSOR_DOMAIN, chem_sensor_data_path + ) continue if gateway.get_data(*chem_sensor_data_path): entities.append( @@ -216,7 +218,9 @@ async def async_setup_entry( scg_sensor_description.key, ) if EQUIPMENT_FLAG.CHLORINATOR not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, scg_sensor_data_path) + cleanup_excluded_entity( + coordinator, BINARY_SENSOR_DOMAIN, scg_sensor_data_path + ) continue if gateway.get_data(*scg_sensor_data_path): entities.append( diff --git a/homeassistant/components/screenlogic/number.py b/homeassistant/components/screenlogic/number.py index c5d67b8f285..d0eb6a71ec8 100644 --- a/homeassistant/components/screenlogic/number.py +++ b/homeassistant/components/screenlogic/number.py @@ -9,7 +9,7 @@ from screenlogicpy.const.msg import CODE from screenlogicpy.device_const.system import EQUIPMENT_FLAG from homeassistant.components.number import ( - DOMAIN, + DOMAIN as NUMBER_DOMAIN, NumberEntity, NumberEntityDescription, NumberMode, @@ -111,7 +111,7 @@ async def async_setup_entry( chem_number_description.key, ) if EQUIPMENT_FLAG.INTELLICHEM not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, chem_number_data_path) + cleanup_excluded_entity(coordinator, NUMBER_DOMAIN, chem_number_data_path) continue if gateway.get_data(*chem_number_data_path): entities.append( @@ -124,7 +124,7 @@ async def async_setup_entry( scg_number_description.key, ) if EQUIPMENT_FLAG.CHLORINATOR not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, scg_number_data_path) + cleanup_excluded_entity(coordinator, NUMBER_DOMAIN, scg_number_data_path) continue if gateway.get_data(*scg_number_data_path): entities.append(ScreenLogicSCGNumber(coordinator, scg_number_description)) diff --git a/homeassistant/components/screenlogic/sensor.py b/homeassistant/components/screenlogic/sensor.py index 0b8e4147420..c580204221f 100644 --- a/homeassistant/components/screenlogic/sensor.py +++ b/homeassistant/components/screenlogic/sensor.py @@ -12,7 +12,7 @@ from screenlogicpy.device_const.pump import PUMP_TYPE from screenlogicpy.device_const.system import EQUIPMENT_FLAG from homeassistant.components.sensor import ( - DOMAIN, + DOMAIN as SENSOR_DOMAIN, SensorDeviceClass, SensorEntity, SensorEntityDescription, @@ -267,7 +267,7 @@ async def async_setup_entry( chem_sensor_description.key, ) if EQUIPMENT_FLAG.INTELLICHEM not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, chem_sensor_data_path) + cleanup_excluded_entity(coordinator, SENSOR_DOMAIN, chem_sensor_data_path) continue if gateway.get_data(*chem_sensor_data_path): chem_sensor_description = dataclasses.replace( @@ -282,7 +282,7 @@ async def async_setup_entry( scg_sensor_description.key, ) if EQUIPMENT_FLAG.CHLORINATOR not in gateway.equipment_flags: - cleanup_excluded_entity(coordinator, DOMAIN, scg_sensor_data_path) + cleanup_excluded_entity(coordinator, SENSOR_DOMAIN, scg_sensor_data_path) continue if gateway.get_data(*scg_sensor_data_path): scg_sensor_description = dataclasses.replace( diff --git a/homeassistant/components/unifi/switch.py b/homeassistant/components/unifi/switch.py index 93a0c81a24e..2af610480fc 100644 --- a/homeassistant/components/unifi/switch.py +++ b/homeassistant/components/unifi/switch.py @@ -35,7 +35,7 @@ from aiounifi.models.traffic_rule import TrafficRule, TrafficRuleEnableRequest from aiounifi.models.wlan import Wlan, WlanEnableRequest from homeassistant.components.switch import ( - DOMAIN, + DOMAIN as SWITCH_DOMAIN, SwitchDeviceClass, SwitchEntity, SwitchEntityDescription, @@ -88,7 +88,7 @@ def async_dpi_group_device_info_fn(hub: UnifiHub, obj_id: str) -> DeviceInfo: """Create device registry entry for DPI group.""" return DeviceInfo( entry_type=DeviceEntryType.SERVICE, - identifiers={(DOMAIN, f"unifi_controller_{obj_id}")}, + identifiers={(SWITCH_DOMAIN, f"unifi_controller_{obj_id}")}, manufacturer=ATTR_MANUFACTURER, model="UniFi Network", name="UniFi Network", @@ -102,7 +102,7 @@ def async_unifi_network_device_info_fn(hub: UnifiHub, obj_id: str) -> DeviceInfo assert unique_id is not None return DeviceInfo( entry_type=DeviceEntryType.SERVICE, - identifiers={(DOMAIN, unique_id)}, + identifiers={(SWITCH_DOMAIN, unique_id)}, manufacturer=ATTR_MANUFACTURER, model="UniFi Network", name="UniFi Network", @@ -307,12 +307,14 @@ 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(DOMAIN, UNIFI_DOMAIN, new_unique_id): + if ent_reg.async_get_entity_id(SWITCH_DOMAIN, UNIFI_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(DOMAIN, UNIFI_DOMAIN, unique_id): + if entity_id := ent_reg.async_get_entity_id( + SWITCH_DOMAIN, UNIFI_DOMAIN, unique_id + ): ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id) for obj_id in hub.api.outlets: diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index c5bd9fb50c4..dda5230466a 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -35,7 +35,7 @@ from homeassistant.components.media_player import ( ATTR_SOUND_MODE, ATTR_SOUND_MODE_LIST, DEVICE_CLASSES_SCHEMA, - DOMAIN, + DOMAIN as MEDIA_PLAYER_DOMAIN, PLATFORM_SCHEMA as MEDIA_PLAYER_PLATFORM_SCHEMA, SERVICE_CLEAR_PLAYLIST, SERVICE_PLAY_MEDIA, @@ -292,7 +292,11 @@ class UniversalMediaPlayer(MediaPlayerEntity): service_data[ATTR_ENTITY_ID] = active_child.entity_id await self.hass.services.async_call( - DOMAIN, service_name, service_data, blocking=True, context=self._context + MEDIA_PLAYER_DOMAIN, + service_name, + service_data, + blocking=True, + context=self._context, ) @property @@ -651,7 +655,9 @@ class UniversalMediaPlayer(MediaPlayerEntity): entity_id = self._browse_media_entity if not entity_id and self._child_state: entity_id = self._child_state.entity_id - component: EntityComponent[MediaPlayerEntity] = self.hass.data[DOMAIN] + component: EntityComponent[MediaPlayerEntity] = self.hass.data[ + MEDIA_PLAYER_DOMAIN + ] if entity_id and (entity := component.get_entity(entity_id)): return await entity.async_browse_media(media_content_type, media_content_id) raise NotImplementedError