This commit is contained in:
G Johansson
2025-10-25 19:45:19 +00:00
parent dace68bd7b
commit fde352b814
4 changed files with 4 additions and 42 deletions

View File

@@ -34,7 +34,7 @@ from homeassistant.components.climate import (
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, entity_registry as er
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.util.unit_conversion import TemperatureConverter
@@ -105,7 +105,6 @@ async def async_setup_entry(
heat_away_temp = entry.options.get(CONF_HEAT_AWAY_TEMPERATURE)
data = entry.runtime_data
_async_migrate_unique_id(hass, data.devices)
async_add_entities(
[
HoneywellUSThermostat(data, device, cool_away_temp, heat_away_temp)
@@ -115,21 +114,6 @@ async def async_setup_entry(
remove_stale_devices(hass, entry, data.devices)
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():
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=str(device.deviceid)
)
def remove_stale_devices(
hass: HomeAssistant,
config_entry: HoneywellConfigEntry,

View File

@@ -69,7 +69,7 @@ class NukiDeviceEntity[_NukiDeviceT: NukiDevice](NukiEntity[_NukiDeviceT], LockE
@property
def unique_id(self) -> str | None:
"""Return a unique ID."""
return self._nuki_device.nuki_id
return str(self._nuki_device.nuki_id)
@property
def available(self) -> bool:

View File

@@ -29,7 +29,6 @@ from homeassistant.components.climate import (
HVACMode,
)
from homeassistant.components.honeywell.climate import (
DOMAIN,
MODE_PERMANENT_HOLD,
MODE_TEMPORARY_HOLD,
PRESET_HOLD,
@@ -41,7 +40,6 @@ from homeassistant.const import (
ATTR_TEMPERATURE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
@@ -1193,26 +1191,6 @@ async def test_async_update_errors(
assert state.state == "unavailable"
async def test_unique_id(
hass: HomeAssistant,
device: MagicMock,
config_entry: MagicMock,
entity_registry: er.EntityRegistry,
) -> None:
"""Test unique id convert to string."""
config_entry.add_to_hass(hass)
entity_registry.async_get_or_create(
Platform.CLIMATE,
DOMAIN,
device.deviceid,
config_entry=config_entry,
suggested_object_id=device.name,
)
await init_integration(hass, config_entry)
entity_entry = entity_registry.async_get(f"climate.{device.name}")
assert entity_entry.unique_id == str(device.deviceid)
async def test_preset_mode(
hass: HomeAssistant,
device: MagicMock,

View File

@@ -30,7 +30,7 @@
'suggested_object_id': None,
'supported_features': <LockEntityFeature: 1>,
'translation_key': 'nuki_lock',
'unique_id': 2,
'unique_id': '2',
'unit_of_measurement': None,
})
# ---
@@ -79,7 +79,7 @@
'suggested_object_id': None,
'supported_features': <LockEntityFeature: 1>,
'translation_key': 'nuki_lock',
'unique_id': 1,
'unique_id': '1',
'unit_of_measurement': None,
})
# ---