Remove ExternalDevice 'invalid ID' migration in HomeWizard (#128634)
This commit is contained in:
parent
6ff2ce1895
commit
4251389c12
2 changed files with 0 additions and 75 deletions
|
@ -19,7 +19,6 @@ from homeassistant.const import (
|
|||
ATTR_VIA_DEVICE,
|
||||
PERCENTAGE,
|
||||
EntityCategory,
|
||||
Platform,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
|
@ -30,7 +29,6 @@ from homeassistant.const import (
|
|||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
@ -625,7 +623,6 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Initialize sensors."""
|
||||
|
||||
ent_reg = er.async_get(hass)
|
||||
data = entry.runtime_data.data.data
|
||||
|
||||
# Initialize default sensors
|
||||
|
@ -639,17 +636,6 @@ async def async_setup_entry(
|
|||
if data.external_devices is not None:
|
||||
for unique_id, device in data.external_devices.items():
|
||||
if description := EXTERNAL_SENSORS.get(device.meter_type):
|
||||
# Migrate external devices to new unique_id
|
||||
# This is to ensure that devices with same id but different type are unique
|
||||
# Migration can be removed after 2024.11.0
|
||||
if entity_id := ent_reg.async_get_entity_id(
|
||||
Platform.SENSOR, DOMAIN, f"{DOMAIN}_{device.unique_id}"
|
||||
):
|
||||
ent_reg.async_update_entity(
|
||||
entity_id,
|
||||
new_unique_id=f"{DOMAIN}_{unique_id}",
|
||||
)
|
||||
|
||||
# Add external device
|
||||
entities.append(
|
||||
HomeWizardExternalSensorEntity(
|
||||
|
|
|
@ -7,9 +7,7 @@ import pytest
|
|||
|
||||
from homeassistant.components.homewizard.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -95,62 +93,3 @@ async def test_load_removes_reauth_flow(
|
|||
# Flow should be removed
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert len(flows) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_fixture", "old_unique_id", "new_unique_id"),
|
||||
[
|
||||
(
|
||||
"HWE-P1",
|
||||
"homewizard_G001",
|
||||
"homewizard_gas_meter_G001",
|
||||
),
|
||||
(
|
||||
"HWE-P1",
|
||||
"homewizard_W001",
|
||||
"homewizard_water_meter_W001",
|
||||
),
|
||||
(
|
||||
"HWE-P1",
|
||||
"homewizard_WW001",
|
||||
"homewizard_warm_water_meter_WW001",
|
||||
),
|
||||
(
|
||||
"HWE-P1",
|
||||
"homewizard_H001",
|
||||
"homewizard_heat_meter_H001",
|
||||
),
|
||||
(
|
||||
"HWE-P1",
|
||||
"homewizard_IH001",
|
||||
"homewizard_inlet_heat_meter_IH001",
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_homewizardenergy")
|
||||
async def test_external_sensor_migration(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
old_unique_id: str,
|
||||
new_unique_id: str,
|
||||
) -> None:
|
||||
"""Test unique ID or External sensors are migrated."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
entity: er.RegistryEntry = entity_registry.async_get_or_create(
|
||||
domain=Platform.SENSOR,
|
||||
platform=DOMAIN,
|
||||
unique_id=old_unique_id,
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
|
||||
assert entity.unique_id == old_unique_id
|
||||
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_migrated = entity_registry.async_get(entity.entity_id)
|
||||
assert entity_migrated
|
||||
assert entity_migrated.unique_id == new_unique_id
|
||||
assert entity_migrated.previous_unique_id == old_unique_id
|
||||
|
|
Loading…
Add table
Reference in a new issue