diff --git a/homeassistant/components/deconz/binary_sensor.py b/homeassistant/components/deconz/binary_sensor.py index 754e5ab427f..3629ff7283e 100644 --- a/homeassistant/components/deconz/binary_sensor.py +++ b/homeassistant/components/deconz/binary_sensor.py @@ -28,12 +28,10 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, EntityCategory from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback -import homeassistant.helpers.entity_registry as er -from .const import ATTR_DARK, ATTR_ON, DOMAIN as DECONZ_DOMAIN +from .const import ATTR_DARK, ATTR_ON from .deconz_device import DeconzDevice from .hub import DeconzHub, get_gateway_from_config_entry -from .util import serial_from_unique_id _SensorDeviceT = TypeVar("_SensorDeviceT", bound=PydeconzSensorBase) @@ -164,29 +162,6 @@ ENTITY_DESCRIPTIONS: tuple[DeconzBinarySensorDescription, ...] = ( ) -@callback -def async_update_unique_id( - hass: HomeAssistant, unique_id: str, description: DeconzBinarySensorDescription -) -> None: - """Update unique ID to always have a suffix. - - Introduced with release 2022.7. - """ - ent_reg = er.async_get(hass) - - new_unique_id = f"{unique_id}-{description.key}" - if ent_reg.async_get_entity_id(DOMAIN, DECONZ_DOMAIN, new_unique_id): - return - - if description.old_unique_id_suffix: - unique_id = ( - f"{serial_from_unique_id(unique_id)}-{description.old_unique_id_suffix}" - ) - - if entity_id := ent_reg.async_get_entity_id(DOMAIN, DECONZ_DOMAIN, unique_id): - ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id) - - async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, @@ -207,7 +182,6 @@ async def async_setup_entry( and not isinstance(sensor, description.instance_check) ) or description.value_fn(sensor) is None: continue - async_update_unique_id(hass, sensor.unique_id, description) async_add_entities([DeconzBinarySensor(sensor, gateway, description)]) gateway.register_platform_add_device_callback( diff --git a/tests/components/deconz/test_binary_sensor.py b/tests/components/deconz/test_binary_sensor.py index ee5a30f2fab..9fd57926f44 100644 --- a/tests/components/deconz/test_binary_sensor.py +++ b/tests/components/deconz/test_binary_sensor.py @@ -4,7 +4,7 @@ from unittest.mock import patch import pytest -from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDeviceClass +from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.deconz.const import ( CONF_ALLOW_CLIP_SENSOR, CONF_ALLOW_NEW_DEVICES, @@ -69,7 +69,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.alarm_10", "unique_id": "00:15:8d:00:02:b5:d1:80-01-0500-alarm", - "old_unique_id": "00:15:8d:00:02:b5:d1:80-01-0500", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.SAFETY, @@ -111,7 +110,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.cave_co", "unique_id": "00:15:8d:00:02:a5:21:24-01-0101-carbon_monoxide", - "old_unique_id": "00:15:8d:00:02:a5:21:24-01-0101", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.CO, @@ -147,7 +145,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.sensor_kitchen_smoke", "unique_id": "00:15:8d:00:01:d9:3e:7c-01-0500-fire", - "old_unique_id": "00:15:8d:00:01:d9:3e:7c-01-0500", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.SMOKE, @@ -184,7 +181,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.sensor_kitchen_smoke_test_mode", "unique_id": "00:15:8d:00:01:d9:3e:7c-01-0500-in_test_mode", - "old_unique_id": "00:15:8d:00:01:d9:3e:7c-test mode", "state": STATE_OFF, "entity_category": EntityCategory.DIAGNOSTIC, "device_class": BinarySensorDeviceClass.SMOKE, @@ -217,7 +213,6 @@ TEST_DATA = [ "device_count": 2, "entity_id": "binary_sensor.kitchen_switch", "unique_id": "kitchen-switch-flag", - "old_unique_id": "kitchen-switch", "state": STATE_ON, "entity_category": None, "device_class": None, @@ -255,7 +250,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.back_door", "unique_id": "00:15:8d:00:02:2b:96:b4-01-0006-open", - "old_unique_id": "00:15:8d:00:02:2b:96:b4-01-0006", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.OPENING, @@ -302,7 +296,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.motion_sensor_4", "unique_id": "00:17:88:01:03:28:8c:9b-02-0406-presence", - "old_unique_id": "00:17:88:01:03:28:8c:9b-02-0406", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.MOTION, @@ -344,7 +337,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.water2", "unique_id": "00:15:8d:00:02:2f:07:db-01-0500-water", - "old_unique_id": "00:15:8d:00:02:2f:07:db-01-0500", "state": STATE_OFF, "entity_category": None, "device_class": BinarySensorDeviceClass.MOISTURE, @@ -390,7 +382,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.vibration_1", "unique_id": "00:15:8d:00:02:a5:21:24-01-0101-vibration", - "old_unique_id": "00:15:8d:00:02:a5:21:24-01-0101", "state": STATE_ON, "entity_category": None, "device_class": BinarySensorDeviceClass.VIBRATION, @@ -429,7 +420,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.presence_sensor_tampered", "unique_id": "00:00:00:00:00:00:00:00-00-tampered", - "old_unique_id": "00:00:00:00:00:00:00:00-tampered", "state": STATE_OFF, "entity_category": EntityCategory.DIAGNOSTIC, "device_class": BinarySensorDeviceClass.TAMPER, @@ -463,7 +453,6 @@ TEST_DATA = [ "device_count": 3, "entity_id": "binary_sensor.presence_sensor_low_battery", "unique_id": "00:00:00:00:00:00:00:00-00-low_battery", - "old_unique_id": "00:00:00:00:00:00:00:00-low battery", "state": STATE_OFF, "entity_category": EntityCategory.DIAGNOSTIC, "device_class": BinarySensorDeviceClass.BATTERY, @@ -489,15 +478,6 @@ async def test_binary_sensors( expected, ) -> None: """Test successful creation of binary sensor entities.""" - - # Create entity entry to migrate to new unique ID - entity_registry.async_get_or_create( - DOMAIN, - DECONZ_DOMAIN, - expected["old_unique_id"], - suggested_object_id=expected["entity_id"].replace(DOMAIN, ""), - ) - with patch.dict(DECONZ_WEB_REQUEST, {"sensors": {"1": sensor_data}}): config_entry = await setup_deconz_integration( hass, aioclient_mock, options={CONF_ALLOW_CLIP_SENSOR: True}