diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index c5cf0bc64c7..9bb61a467cb 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -625,26 +625,8 @@ async def async_setup_entry( ) -> None: """Initialize sensors.""" - # Migrate original gas meter sensor to ExternalDevice - # This is sensor that was directly linked to the P1 Meter - # Migration can be removed after 2024.8.0 ent_reg = er.async_get(hass) data = entry.runtime_data.data.data - if ( - entity_id := ent_reg.async_get_entity_id( - Platform.SENSOR, DOMAIN, f"{entry.unique_id}_total_gas_m3" - ) - ) and data.gas_unique_id is not None: - ent_reg.async_update_entity( - entity_id, - new_unique_id=f"{DOMAIN}_gas_meter_{data.gas_unique_id}", - ) - - # Remove old gas_unique_id sensor - if entity_id := ent_reg.async_get_entity_id( - Platform.SENSOR, DOMAIN, f"{entry.unique_id}_gas_unique_id" - ): - ent_reg.async_remove(entity_id) # Initialize default sensors entities: list = [ diff --git a/tests/components/homewizard/snapshots/test_sensor.ambr b/tests/components/homewizard/snapshots/test_sensor.ambr index dd50b098d40..5d5b458dccc 100644 --- a/tests/components/homewizard/snapshots/test_sensor.ambr +++ b/tests/components/homewizard/snapshots/test_sensor.ambr @@ -1,37 +1,4 @@ # serializer version: 1 -# name: test_gas_meter_migrated[sensor.homewizard_aabbccddeeff_total_gas_m3:entity-registry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.homewizard_aabbccddeeff_total_gas_m3', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': None, - 'platform': 'homewizard', - 'previous_unique_id': 'aabbccddeeff_total_gas_m3', - 'supported_features': 0, - 'translation_key': None, - 'unique_id': 'homewizard_gas_meter_01FFEEDDCCBBAA99887766554433221100', - 'unit_of_measurement': None, - }) -# --- # name: test_sensors[HWE-KWH1-entity_ids7][sensor.device_apparent_power:device-registry] DeviceRegistryEntrySnapshot({ 'area_id': None, diff --git a/tests/components/homewizard/test_sensor.py b/tests/components/homewizard/test_sensor.py index abcd6a879c5..c180c2a4def 100644 --- a/tests/components/homewizard/test_sensor.py +++ b/tests/components/homewizard/test_sensor.py @@ -7,14 +7,13 @@ from homewizard_energy.models import Data import pytest from syrupy.assertion import SnapshotAssertion -from homeassistant.components.homewizard import DOMAIN from homeassistant.components.homewizard.const import UPDATE_INTERVAL -from homeassistant.const import STATE_UNAVAILABLE, Platform +from homeassistant.const import STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er import homeassistant.util.dt as dt_util -from tests.common import MockConfigEntry, async_fire_time_changed +from tests.common import async_fire_time_changed pytestmark = [ pytest.mark.usefixtures("init_integration"), @@ -815,49 +814,3 @@ async def test_entities_not_created_for_device( """Ensures entities for a specific device are not created.""" for entity_id in entity_ids: assert not hass.states.get(entity_id) - - -async def test_gas_meter_migrated( - hass: HomeAssistant, - entity_registry: er.EntityRegistry, - init_integration: MockConfigEntry, - snapshot: SnapshotAssertion, -) -> None: - """Test old gas meter sensor is migrated.""" - entity_registry.async_get_or_create( - Platform.SENSOR, - DOMAIN, - "aabbccddeeff_total_gas_m3", - ) - - await hass.config_entries.async_reload(init_integration.entry_id) - await hass.async_block_till_done() - - entity_id = "sensor.homewizard_aabbccddeeff_total_gas_m3" - - assert (entity_entry := entity_registry.async_get(entity_id)) - assert snapshot(name=f"{entity_id}:entity-registry") == entity_entry - - # Make really sure this happens - assert entity_entry.previous_unique_id == "aabbccddeeff_total_gas_m3" - - -async def test_gas_unique_id_removed( - hass: HomeAssistant, - entity_registry: er.EntityRegistry, - init_integration: MockConfigEntry, - snapshot: SnapshotAssertion, -) -> None: - """Test old gas meter id sensor is removed.""" - entity_registry.async_get_or_create( - Platform.SENSOR, - DOMAIN, - "aabbccddeeff_gas_unique_id", - ) - - await hass.config_entries.async_reload(init_integration.entry_id) - await hass.async_block_till_done() - - entity_id = "sensor.homewizard_aabbccddeeff_gas_unique_id" - - assert not entity_registry.async_get(entity_id)