1
mirror of https://github.com/home-assistant/core synced 2024-09-28 03:04:04 +02:00

Remove old migrate unique ID code from ISY994 (#85641)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
shbatm 2023-01-10 16:42:31 -06:00 committed by GitHub
parent d3249432c9
commit 856895ddf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 4 additions and 66 deletions

View File

@ -45,7 +45,6 @@ from .const import (
TYPE_INSTEON_MOTION,
)
from .entity import ISYNodeEntity, ISYProgramEntity
from .helpers import migrate_old_unique_ids
DEVICE_PARENT_REQUIRED = [
BinarySensorDeviceClass.OPENING,
@ -191,7 +190,6 @@ async def async_setup_entry(
for name, status, _ in hass_isy_data[ISY994_PROGRAMS][Platform.BINARY_SENSOR]:
entities.append(ISYBinarySensorProgramEntity(name, status))
await migrate_old_unique_ids(hass, Platform.BINARY_SENSOR, entities)
async_add_entities(entities)

View File

@ -54,7 +54,7 @@ from .const import (
UOM_TO_STATES,
)
from .entity import ISYNodeEntity
from .helpers import convert_isy_value_to_hass, migrate_old_unique_ids
from .helpers import convert_isy_value_to_hass
async def async_setup_entry(
@ -67,7 +67,6 @@ async def async_setup_entry(
for node in hass_isy_data[ISY994_NODES][Platform.CLIMATE]:
entities.append(ISYThermostatEntity(node))
await migrate_old_unique_ids(hass, Platform.CLIMATE, entities)
async_add_entities(entities)

View File

@ -24,7 +24,6 @@ from .const import (
UOM_BARRIER,
)
from .entity import ISYNodeEntity, ISYProgramEntity
from .helpers import migrate_old_unique_ids
async def async_setup_entry(
@ -39,7 +38,6 @@ async def async_setup_entry(
for name, status, actions in hass_isy_data[ISY994_PROGRAMS][Platform.COVER]:
entities.append(ISYCoverProgramEntity(name, status, actions))
await migrate_old_unique_ids(hass, Platform.COVER, entities)
async_add_entities(entities)

View File

@ -1,7 +1,7 @@
"""Representation of ISYEntity Types."""
from __future__ import annotations
from typing import Any, cast
from typing import Any
from pyisy.constants import (
COMMAND_FRIENDLY_NAME,
@ -130,13 +130,6 @@ class ISYEntity(Entity):
return f"{self._node.isy.configuration[ISY_CONF_UUID]}_{self._node.address}"
return None
@property
def old_unique_id(self) -> str | None:
"""Get the old unique identifier of the device."""
if hasattr(self._node, "address"):
return cast(str, self._node.address)
return None
@property
def name(self) -> str:
"""Get the name of the device."""

View File

@ -19,7 +19,6 @@ from homeassistant.util.percentage import (
from .const import _LOGGER, DOMAIN as ISY994_DOMAIN, ISY994_NODES, ISY994_PROGRAMS
from .entity import ISYNodeEntity, ISYProgramEntity
from .helpers import migrate_old_unique_ids
SPEED_RANGE = (1, 255) # off is not included
@ -37,7 +36,6 @@ async def async_setup_entry(
for name, status, actions in hass_isy_data[ISY994_PROGRAMS][Platform.FAN]:
entities.append(ISYFanProgramEntity(name, status, actions))
await migrate_old_unique_ids(hass, Platform.FAN, entities)
async_add_entities(entities)

View File

@ -1,8 +1,7 @@
"""Sorting helpers for ISY device classifications."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, cast
from typing import cast
from pyisy.constants import (
ISY_VALUE_UNKNOWN,
@ -17,13 +16,10 @@ from pyisy.programs import Programs
from pyisy.variables import Variables
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .const import (
_LOGGER,
DEFAULT_PROGRAM_STRING,
DOMAIN,
FILTER_INSTEON_TYPE,
FILTER_NODE_DEF_ID,
FILTER_STATES,
@ -50,9 +46,6 @@ from .const import (
UOM_ISYV4_DEGREES,
)
if TYPE_CHECKING:
from .entity import ISYEntity
BINARY_SENSOR_UOMS = ["2", "78"]
BINARY_SENSOR_ISY_STATES = ["on", "off"]
@ -381,40 +374,6 @@ def _categorize_variables(
variable_entities[Platform.SENSOR].append((vname, variables[vtype][vid]))
async def migrate_old_unique_ids(
hass: HomeAssistant, platform: str, entities: Sequence[ISYEntity]
) -> None:
"""Migrate to new controller-specific unique ids."""
registry = er.async_get(hass)
for entity in entities:
if entity.old_unique_id is None or entity.unique_id is None:
continue
old_entity_id = registry.async_get_entity_id(
platform, DOMAIN, entity.old_unique_id
)
if old_entity_id is not None:
_LOGGER.debug(
"Migrating unique_id from [%s] to [%s]",
entity.old_unique_id,
entity.unique_id,
)
registry.async_update_entity(old_entity_id, new_unique_id=entity.unique_id)
old_entity_id_2 = registry.async_get_entity_id(
platform, DOMAIN, entity.unique_id.replace(":", "")
)
if old_entity_id_2 is not None:
_LOGGER.debug(
"Migrating unique_id from [%s] to [%s]",
entity.unique_id.replace(":", ""),
entity.unique_id,
)
registry.async_update_entity(
old_entity_id_2, new_unique_id=entity.unique_id
)
def convert_isy_value_to_hass(
value: int | float | None,
uom: str | None,

View File

@ -22,7 +22,6 @@ from .const import (
UOM_PERCENTAGE,
)
from .entity import ISYNodeEntity
from .helpers import migrate_old_unique_ids
from .services import async_setup_light_services
ATTR_LAST_BRIGHTNESS = "last_brightness"
@ -40,7 +39,6 @@ async def async_setup_entry(
for node in hass_isy_data[ISY994_NODES][Platform.LIGHT]:
entities.append(ISYLightEntity(node, restore_light_state))
await migrate_old_unique_ids(hass, Platform.LIGHT, entities)
async_add_entities(entities)
async_setup_light_services(hass)

View File

@ -13,7 +13,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import _LOGGER, DOMAIN as ISY994_DOMAIN, ISY994_NODES, ISY994_PROGRAMS
from .entity import ISYNodeEntity, ISYProgramEntity
from .helpers import migrate_old_unique_ids
VALUE_TO_STATE = {0: False, 100: True}
@ -30,7 +29,6 @@ async def async_setup_entry(
for name, status, actions in hass_isy_data[ISY994_PROGRAMS][Platform.LOCK]:
entities.append(ISYLockProgramEntity(name, status, actions))
await migrate_old_unique_ids(hass, Platform.LOCK, entities)
async_add_entities(entities)

View File

@ -45,7 +45,7 @@ from .const import (
UOM_TO_STATES,
)
from .entity import ISYEntity, ISYNodeEntity
from .helpers import convert_isy_value_to_hass, migrate_old_unique_ids
from .helpers import convert_isy_value_to_hass
# Disable general purpose and redundant sensors by default
AUX_DISABLED_BY_DEFAULT_MATCH = ["GV", "DO"]
@ -135,7 +135,6 @@ async def async_setup_entry(
for vname, vobj in hass_isy_data[ISY994_VARIABLES][Platform.SENSOR]:
entities.append(ISYSensorVariableEntity(vname, vobj))
await migrate_old_unique_ids(hass, Platform.SENSOR, entities)
async_add_entities(entities)

View File

@ -13,7 +13,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import _LOGGER, DOMAIN as ISY994_DOMAIN, ISY994_NODES, ISY994_PROGRAMS
from .entity import ISYNodeEntity, ISYProgramEntity
from .helpers import migrate_old_unique_ids
async def async_setup_entry(
@ -28,7 +27,6 @@ async def async_setup_entry(
for name, status, actions in hass_isy_data[ISY994_PROGRAMS][Platform.SWITCH]:
entities.append(ISYSwitchProgramEntity(name, status, actions))
await migrate_old_unique_ids(hass, Platform.SWITCH, entities)
async_add_entities(entities)