From 90d371059c9a3485a321f1d4df476ae761aefdd4 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 3 May 2024 18:56:09 +0000 Subject: [PATCH 1/5] Update unique_id to string --- homeassistant/components/honeywell/climate.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index ff63d66230d..7f618e4e25c 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -35,7 +35,11 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError, ServiceValidationError -from homeassistant.helpers import device_registry as dr, issue_registry as ir +from homeassistant.helpers import ( + device_registry as dr, + entity_registry as er, + issue_registry as ir, +) from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -99,7 +103,7 @@ async def async_setup_entry( heat_away_temp = entry.options.get(CONF_HEAT_AWAY_TEMPERATURE) data: HoneywellData = hass.data[DOMAIN][entry.entry_id] - + _async_migrate_unique_id(hass, data.devices) async_add_entities( [ HoneywellUSThermostat(data, device, cool_away_temp, heat_away_temp) @@ -109,6 +113,19 @@ async def async_setup_entry( remove_stale_devices(hass, entry, data.devices) +def _async_migrate_unique_id(hass: HomeAssistant, devices) -> None: + """Migrate entities to string.""" + entity_registry = er.async_get(hass) + for device in devices.values(): + entity_id = entity_registry.async_get_entity_id( + "climate", DOMAIN, device.deviceid + ) + if entity_id is not None: + entity_registry.async_update_entity( + entity_id, new_unique_id=f"{device.deviceid}" + ) + + def remove_stale_devices( hass: HomeAssistant, config_entry: ConfigEntry, @@ -161,7 +178,8 @@ class HoneywellUSThermostat(ClimateEntity): self._away = False self._retry = 0 - self._attr_unique_id = device.deviceid + self._attr_unique_id = f"{device.deviceid}" + # self._attr_unique_id = device.deviceid self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, device.deviceid)}, From e700557d50d6424c852153286ce8bb2ab1f5ab15 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 3 May 2024 15:02:37 -0400 Subject: [PATCH 2/5] Update homeassistant/components/honeywell/climate.py Co-authored-by: Joost Lekkerkerker --- homeassistant/components/honeywell/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 7f618e4e25c..5cacb8ccd70 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -178,7 +178,7 @@ class HoneywellUSThermostat(ClimateEntity): self._away = False self._retry = 0 - self._attr_unique_id = f"{device.deviceid}" + self._attr_unique_id = str(device.deviceid) # self._attr_unique_id = device.deviceid self._attr_device_info = DeviceInfo( From 5c7e1961b4ab91173f36d3a2a962b086c38744d7 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 3 May 2024 15:03:22 -0400 Subject: [PATCH 3/5] Update homeassistant/components/honeywell/climate.py Co-authored-by: Joost Lekkerkerker --- homeassistant/components/honeywell/climate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 5cacb8ccd70..4d435a2e516 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -179,7 +179,6 @@ class HoneywellUSThermostat(ClimateEntity): self._retry = 0 self._attr_unique_id = str(device.deviceid) - # self._attr_unique_id = device.deviceid self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, device.deviceid)}, From dbd3586440c057b257808486d3ff8e0bf77c4ed0 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 3 May 2024 15:03:55 -0400 Subject: [PATCH 4/5] Update homeassistant/components/honeywell/climate.py Co-authored-by: Joost Lekkerkerker --- homeassistant/components/honeywell/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 4d435a2e516..fb844ca43de 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -122,7 +122,7 @@ def _async_migrate_unique_id(hass: HomeAssistant, devices) -> None: ) if entity_id is not None: entity_registry.async_update_entity( - entity_id, new_unique_id=f"{device.deviceid}" + entity_id, new_unique_id=str(device.deviceid) ) From 4b01f4bcc35b84cf2fc35afda7f7142cf2347746 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 3 May 2024 19:10:40 +0000 Subject: [PATCH 5/5] Add typing for devices --- homeassistant/components/honeywell/climate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index fb844ca43de..f9a1cc54c7a 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -113,7 +113,9 @@ async def async_setup_entry( remove_stale_devices(hass, entry, data.devices) -def _async_migrate_unique_id(hass: HomeAssistant, devices) -> None: +def _async_migrate_unique_id( + hass: HomeAssistant, devices: dict[str, SomeComfortDevice] +) -> None: """Migrate entities to string.""" entity_registry = er.async_get(hass) for device in devices.values():