mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 05:06:13 +01:00
Rename DOMAIN aliases (#163253)
This commit is contained in:
@@ -7,7 +7,7 @@ import logging
|
||||
|
||||
from accuweather import AccuWeather
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_PLATFORM
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import CONF_API_KEY, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
@@ -72,7 +72,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AccuWeatherConfigEntry)
|
||||
ent_reg = er.async_get(hass)
|
||||
for day in range(5):
|
||||
unique_id = f"{location_key}-ozone-{day}"
|
||||
if entity_id := ent_reg.async_get_entity_id(SENSOR_PLATFORM, DOMAIN, unique_id):
|
||||
if entity_id := ent_reg.async_get_entity_id(SENSOR_DOMAIN, DOMAIN, unique_id):
|
||||
_LOGGER.debug("Removing ozone sensor entity %s", entity_id)
|
||||
ent_reg.async_remove(entity_id)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_DOMAIN
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
@@ -75,9 +75,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirlyConfigEntry) -> boo
|
||||
# Remove air_quality entities from registry if they exist
|
||||
ent_reg = er.async_get(hass)
|
||||
unique_id = f"{coordinator.latitude}-{coordinator.longitude}"
|
||||
if entity_id := ent_reg.async_get_entity_id(
|
||||
AIR_QUALITY_PLATFORM, DOMAIN, unique_id
|
||||
):
|
||||
if entity_id := ent_reg.async_get_entity_id(AIR_QUALITY_DOMAIN, DOMAIN, unique_id):
|
||||
_LOGGER.debug("Removing deprecated air_quality entity %s", entity_id)
|
||||
ent_reg.async_remove(entity_id)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import logging
|
||||
from brother import BrotherSensors
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as PLATFORM,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
@@ -314,7 +314,7 @@ async def async_setup_entry(
|
||||
entity_registry = er.async_get(hass)
|
||||
old_unique_id = f"{coordinator.brother.serial.lower()}_b/w_counter"
|
||||
if entity_id := entity_registry.async_get_entity_id(
|
||||
PLATFORM, DOMAIN, old_unique_id
|
||||
SENSOR_DOMAIN, DOMAIN, old_unique_id
|
||||
):
|
||||
new_unique_id = f"{coordinator.brother.serial.lower()}_bw_counter"
|
||||
_LOGGER.debug(
|
||||
|
||||
@@ -9,7 +9,7 @@ import logging
|
||||
from gios.model import GiosSensors
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as PLATFORM,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
@@ -187,7 +187,7 @@ async def async_setup_entry(
|
||||
entity_registry = er.async_get(hass)
|
||||
old_unique_id = f"{coordinator.gios.station_id}-pm2.5"
|
||||
if entity_id := entity_registry.async_get_entity_id(
|
||||
PLATFORM, DOMAIN, old_unique_id
|
||||
SENSOR_DOMAIN, DOMAIN, old_unique_id
|
||||
):
|
||||
new_unique_id = f"{coordinator.gios.station_id}-{ATTR_PM25}"
|
||||
_LOGGER.debug(
|
||||
|
||||
@@ -23,7 +23,7 @@ from pycec.network import HDMINetwork, PhysicalAddress
|
||||
from pycec.tcp import TcpAdapter
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICES,
|
||||
@@ -122,11 +122,11 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
vol.Optional(CONF_DEVICES): vol.Any(
|
||||
DEVICE_SCHEMA, vol.Schema({vol.All(cv.string): vol.Any(cv.string)})
|
||||
),
|
||||
vol.Optional(CONF_PLATFORM): vol.Any(SWITCH, MEDIA_PLAYER),
|
||||
vol.Optional(CONF_PLATFORM): vol.Any(SWITCH, MEDIA_PLAYER_DOMAIN),
|
||||
vol.Optional(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_DISPLAY_NAME): cv.string,
|
||||
vol.Optional(CONF_TYPES, default={}): vol.Schema(
|
||||
{cv.entity_id: vol.Any(MEDIA_PLAYER, SWITCH)}
|
||||
{cv.entity_id: vol.Any(MEDIA_PLAYER_DOMAIN, SWITCH)}
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from aiohttp import ClientError
|
||||
from imgw_pib import ImgwPib
|
||||
from imgw_pib.exceptions import ApiError
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_PLATFORM
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
@@ -54,7 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ImgwPibConfigEntry) -> b
|
||||
entity_reg = er.async_get(hass)
|
||||
for key in ("flood_warning", "flood_alarm"):
|
||||
if entity_id := entity_reg.async_get_entity_id(
|
||||
BINARY_SENSOR_PLATFORM, DOMAIN, f"{coordinator.station_id}_{key}"
|
||||
BINARY_SENSOR_DOMAIN, DOMAIN, f"{coordinator.station_id}_{key}"
|
||||
):
|
||||
entity_reg.async_remove(entity_id)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from imgw_pib.const import HYDROLOGICAL_ALERTS_MAP, NO_ALERT
|
||||
from imgw_pib.model import HydrologicalData
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as SENSOR_PLATFORM,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
@@ -102,7 +102,7 @@ async def async_setup_entry(
|
||||
entity_reg = er.async_get(hass)
|
||||
for key in ("flood_warning_level", "flood_alarm_level"):
|
||||
if entity_id := entity_reg.async_get_entity_id(
|
||||
SENSOR_PLATFORM, DOMAIN, f"{coordinator.station_id}_{key}"
|
||||
SENSOR_DOMAIN, DOMAIN, f"{coordinator.station_id}_{key}"
|
||||
):
|
||||
entity_reg.async_remove(entity_id)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
DOMAIN as DEVICE_TRACKER,
|
||||
DOMAIN as DEVICE_TRACKER_DOMAIN,
|
||||
ScannerEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@@ -33,7 +33,7 @@ async def async_setup_entry(
|
||||
for entity in registry.entities.get_entries_for_config_entry_id(
|
||||
config_entry.entry_id
|
||||
):
|
||||
if entity.domain == DEVICE_TRACKER:
|
||||
if entity.domain == DEVICE_TRACKER_DOMAIN:
|
||||
if (
|
||||
entity.unique_id in coordinator.api.devices
|
||||
or entity.unique_id not in coordinator.api.all_devices
|
||||
|
||||
@@ -12,7 +12,7 @@ from nettigo_air_monitor import (
|
||||
NettigoAirMonitor,
|
||||
)
|
||||
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
@@ -63,7 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: NAMConfigEntry) -> bool:
|
||||
for sensor_type in ("sds", ATTR_SDS011, ATTR_SPS30):
|
||||
unique_id = f"{coordinator.unique_id}-{sensor_type}"
|
||||
if entity_id := ent_reg.async_get_entity_id(
|
||||
AIR_QUALITY_PLATFORM, DOMAIN, unique_id
|
||||
AIR_QUALITY_DOMAIN, DOMAIN, unique_id
|
||||
):
|
||||
_LOGGER.debug("Removing deprecated air_quality entity %s", entity_id)
|
||||
ent_reg.async_remove(entity_id)
|
||||
|
||||
@@ -10,7 +10,7 @@ import logging
|
||||
from nettigo_air_monitor import NAMSensors
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as PLATFORM,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
@@ -381,7 +381,9 @@ async def async_setup_entry(
|
||||
for old_sensor, new_sensor in MIGRATION_SENSORS:
|
||||
old_unique_id = f"{coordinator.unique_id}-{old_sensor}"
|
||||
new_unique_id = f"{coordinator.unique_id}-{new_sensor}"
|
||||
if entity_id := ent_reg.async_get_entity_id(PLATFORM, DOMAIN, old_unique_id):
|
||||
if entity_id := ent_reg.async_get_entity_id(
|
||||
SENSOR_DOMAIN, DOMAIN, old_unique_id
|
||||
):
|
||||
_LOGGER.debug(
|
||||
"Migrating entity %s from old unique ID '%s' to new unique ID '%s'",
|
||||
entity_id,
|
||||
|
||||
@@ -22,7 +22,7 @@ from pyplaato.plaato import (
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import webhook
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
@@ -57,7 +57,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
DEPENDENCIES = ["webhook"]
|
||||
|
||||
SENSOR_UPDATE = f"{DOMAIN}_sensor_update"
|
||||
SENSOR_DATA_KEY = f"{DOMAIN}.{SENSOR}"
|
||||
SENSOR_DATA_KEY = f"{DOMAIN}.{SENSOR_DOMAIN}"
|
||||
|
||||
WEBHOOK_SCHEMA = vol.Schema(
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Final, cast
|
||||
from aioshelly.const import MODEL_FLOOD_G4, RPC_GENERATIONS
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN as BINARY_SENSOR_PLATFORM,
|
||||
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
@@ -292,7 +292,7 @@ RPC_SENSORS: Final = {
|
||||
key="boolean",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, BINARY_SENSOR_PLATFORM)
|
||||
not is_view_for_platform(config, key, BINARY_SENSOR_DOMAIN)
|
||||
),
|
||||
role=ROLE_GENERIC,
|
||||
),
|
||||
@@ -424,7 +424,7 @@ def _async_setup_rpc_entry(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
BINARY_SENSOR_PLATFORM,
|
||||
BINARY_SENSOR_DOMAIN,
|
||||
coordinator.device.status,
|
||||
)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from aioshelly.const import BLU_TRV_IDENTIFIER, MODEL_BLU_GATEWAY_G3, RPC_GENERA
|
||||
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError, RpcCallError
|
||||
|
||||
from homeassistant.components.button import (
|
||||
DOMAIN as BUTTON_PLATFORM,
|
||||
DOMAIN as BUTTON_DOMAIN,
|
||||
ButtonDeviceClass,
|
||||
ButtonEntity,
|
||||
ButtonEntityDescription,
|
||||
@@ -217,7 +217,7 @@ async def async_setup_entry(
|
||||
# added in https://github.com/home-assistant/core/pull/154673
|
||||
entry_sleep_period = config_entry.data[CONF_SLEEP_PERIOD]
|
||||
if device_gen in RPC_GENERATIONS and entry_sleep_period:
|
||||
async_remove_shelly_entity(hass, BUTTON_PLATFORM, f"{coordinator.mac}-reboot")
|
||||
async_remove_shelly_entity(hass, BUTTON_DOMAIN, f"{coordinator.mac}-reboot")
|
||||
|
||||
entities: list[ShellyButton] = []
|
||||
|
||||
@@ -249,13 +249,13 @@ async def async_setup_entry(
|
||||
# the user can remove virtual components from the device configuration, so
|
||||
# we need to remove orphaned entities
|
||||
virtual_button_component_ids = get_virtual_component_ids(
|
||||
coordinator.device.config, BUTTON_PLATFORM
|
||||
coordinator.device.config, BUTTON_DOMAIN
|
||||
)
|
||||
async_remove_orphaned_entities(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
BUTTON_PLATFORM,
|
||||
BUTTON_DOMAIN,
|
||||
virtual_button_component_ids,
|
||||
)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from aioshelly.const import RPC_GENERATIONS
|
||||
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError
|
||||
|
||||
from homeassistant.components.number import (
|
||||
DOMAIN as NUMBER_PLATFORM,
|
||||
DOMAIN as NUMBER_DOMAIN,
|
||||
NumberDeviceClass,
|
||||
NumberEntity,
|
||||
NumberEntityDescription,
|
||||
@@ -210,7 +210,7 @@ RPC_NUMBERS: Final = {
|
||||
key="number",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, NUMBER_PLATFORM)
|
||||
not is_view_for_platform(config, key, NUMBER_DOMAIN)
|
||||
),
|
||||
max_fn=lambda config: config["max"],
|
||||
min_fn=lambda config: config["min"],
|
||||
@@ -380,13 +380,13 @@ def _async_setup_rpc_entry(
|
||||
# the user can remove virtual components from the device configuration, so
|
||||
# we need to remove orphaned entities
|
||||
virtual_number_ids = get_virtual_component_ids(
|
||||
coordinator.device.config, NUMBER_PLATFORM
|
||||
coordinator.device.config, NUMBER_DOMAIN
|
||||
)
|
||||
async_remove_orphaned_entities(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
NUMBER_PLATFORM,
|
||||
NUMBER_DOMAIN,
|
||||
virtual_number_ids,
|
||||
"number",
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Final
|
||||
from aioshelly.const import RPC_GENERATIONS
|
||||
|
||||
from homeassistant.components.select import (
|
||||
DOMAIN as SELECT_PLATFORM,
|
||||
DOMAIN as SELECT_DOMAIN,
|
||||
SelectEntity,
|
||||
SelectEntityDescription,
|
||||
)
|
||||
@@ -117,7 +117,7 @@ RPC_SELECT_ENTITIES: Final = {
|
||||
key="enum",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _status, key: (
|
||||
not is_view_for_platform(config, key, SELECT_PLATFORM)
|
||||
not is_view_for_platform(config, key, SELECT_DOMAIN)
|
||||
),
|
||||
method="enum_set",
|
||||
role=ROLE_GENERIC,
|
||||
@@ -154,13 +154,13 @@ def _async_setup_rpc_entry(
|
||||
# the user can remove virtual components from the device configuration, so
|
||||
# we need to remove orphaned entities
|
||||
virtual_text_ids = get_virtual_component_ids(
|
||||
coordinator.device.config, SELECT_PLATFORM
|
||||
coordinator.device.config, SELECT_DOMAIN
|
||||
)
|
||||
async_remove_orphaned_entities(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
SELECT_PLATFORM,
|
||||
SELECT_DOMAIN,
|
||||
virtual_text_ids,
|
||||
"enum",
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ from aioshelly.block_device import Block
|
||||
from aioshelly.const import RPC_GENERATIONS
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as SENSOR_PLATFORM,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
RestoreSensor,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
@@ -1357,7 +1357,7 @@ RPC_SENSORS: Final = {
|
||||
key="text",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, SENSOR_PLATFORM)
|
||||
not is_view_for_platform(config, key, SENSOR_DOMAIN)
|
||||
),
|
||||
role=ROLE_GENERIC,
|
||||
),
|
||||
@@ -1365,7 +1365,7 @@ RPC_SENSORS: Final = {
|
||||
key="number",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, SENSOR_PLATFORM)
|
||||
not is_view_for_platform(config, key, SENSOR_DOMAIN)
|
||||
),
|
||||
unit=get_virtual_component_unit,
|
||||
role=ROLE_GENERIC,
|
||||
@@ -1374,7 +1374,7 @@ RPC_SENSORS: Final = {
|
||||
key="enum",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, SENSOR_PLATFORM)
|
||||
not is_view_for_platform(config, key, SENSOR_DOMAIN)
|
||||
),
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
role=ROLE_GENERIC,
|
||||
@@ -1792,7 +1792,7 @@ def _async_setup_rpc_entry(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
SENSOR_PLATFORM,
|
||||
SENSOR_DOMAIN,
|
||||
coordinator.device.status,
|
||||
)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ from typing import TYPE_CHECKING, Any, cast
|
||||
from aioshelly.block_device import Block
|
||||
from aioshelly.const import RPC_GENERATIONS
|
||||
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_PLATFORM
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
||||
from homeassistant.components.switch import (
|
||||
DOMAIN as SWITCH_PLATFORM,
|
||||
DOMAIN as SWITCH_DOMAIN,
|
||||
SwitchEntity,
|
||||
SwitchEntityDescription,
|
||||
)
|
||||
@@ -101,7 +101,7 @@ RPC_SWITCHES = {
|
||||
key="boolean",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _, key: (
|
||||
not is_view_for_platform(config, key, SWITCH_PLATFORM)
|
||||
not is_view_for_platform(config, key, SWITCH_DOMAIN)
|
||||
),
|
||||
is_on=lambda status: bool(status["value"]),
|
||||
method_on="boolean_set",
|
||||
@@ -379,13 +379,13 @@ def _async_setup_rpc_entry(
|
||||
# the user can remove virtual components from the device configuration, so we need
|
||||
# to remove orphaned entities
|
||||
virtual_switch_ids = get_virtual_component_ids(
|
||||
coordinator.device.config, SWITCH_PLATFORM
|
||||
coordinator.device.config, SWITCH_DOMAIN
|
||||
)
|
||||
async_remove_orphaned_entities(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
SWITCH_PLATFORM,
|
||||
SWITCH_DOMAIN,
|
||||
virtual_switch_ids,
|
||||
"boolean",
|
||||
)
|
||||
@@ -396,7 +396,7 @@ def _async_setup_rpc_entry(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
SWITCH_PLATFORM,
|
||||
SWITCH_DOMAIN,
|
||||
coordinator.device.status,
|
||||
"script",
|
||||
)
|
||||
@@ -407,7 +407,7 @@ def _async_setup_rpc_entry(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
CLIMATE_PLATFORM,
|
||||
CLIMATE_DOMAIN,
|
||||
coordinator.device.status,
|
||||
"thermostat",
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Final
|
||||
from aioshelly.const import RPC_GENERATIONS
|
||||
|
||||
from homeassistant.components.text import (
|
||||
DOMAIN as TEXT_PLATFORM,
|
||||
DOMAIN as TEXT_DOMAIN,
|
||||
TextEntity,
|
||||
TextEntityDescription,
|
||||
)
|
||||
@@ -44,7 +44,7 @@ RPC_TEXT_ENTITIES: Final = {
|
||||
key="text",
|
||||
sub_key="value",
|
||||
removal_condition=lambda config, _status, key: (
|
||||
not is_view_for_platform(config, key, TEXT_PLATFORM)
|
||||
not is_view_for_platform(config, key, TEXT_DOMAIN)
|
||||
),
|
||||
role=ROLE_GENERIC,
|
||||
),
|
||||
@@ -79,14 +79,12 @@ def _async_setup_rpc_entry(
|
||||
|
||||
# the user can remove virtual components from the device configuration, so
|
||||
# we need to remove orphaned entities
|
||||
virtual_text_ids = get_virtual_component_ids(
|
||||
coordinator.device.config, TEXT_PLATFORM
|
||||
)
|
||||
virtual_text_ids = get_virtual_component_ids(coordinator.device.config, TEXT_DOMAIN)
|
||||
async_remove_orphaned_entities(
|
||||
hass,
|
||||
config_entry.entry_id,
|
||||
coordinator.mac,
|
||||
TEXT_PLATFORM,
|
||||
TEXT_DOMAIN,
|
||||
virtual_text_ids,
|
||||
"text",
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any
|
||||
|
||||
import aiotractive
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_PLATFORM
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_CHARGING,
|
||||
@@ -136,7 +136,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TractiveConfigEntry) ->
|
||||
for item in filtered_trackables:
|
||||
for key in ("activity_label", "calories", "sleep_label"):
|
||||
if entity_id := entity_reg.async_get_entity_id(
|
||||
SENSOR_PLATFORM, DOMAIN, f"{item.trackable['_id']}_{key}"
|
||||
SENSOR_DOMAIN, DOMAIN, f"{item.trackable['_id']}_{key}"
|
||||
):
|
||||
entity_reg.async_remove(entity_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user