mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Remove deprecated entity migration from opentherm_gw (#139641)
This commit is contained in:
parent
d006d33dc0
commit
de4540c68e
@ -9,7 +9,6 @@ import pyotgw.vars as gw_vars
|
|||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DATE,
|
ATTR_DATE,
|
||||||
@ -25,11 +24,7 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
config_validation as cv,
|
|
||||||
device_registry as dr,
|
|
||||||
entity_registry as er,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -87,18 +82,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
gateway = OpenThermGatewayHub(hass, config_entry)
|
gateway = OpenThermGatewayHub(hass, config_entry)
|
||||||
hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]] = gateway
|
hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]] = gateway
|
||||||
|
|
||||||
# Migration can be removed in 2025.4.0
|
|
||||||
ent_reg = er.async_get(hass)
|
|
||||||
if (
|
|
||||||
entity_id := ent_reg.async_get_entity_id(
|
|
||||||
CLIMATE_DOMAIN, DOMAIN, config_entry.data[CONF_ID]
|
|
||||||
)
|
|
||||||
) is not None:
|
|
||||||
ent_reg.async_update_entity(
|
|
||||||
entity_id,
|
|
||||||
new_unique_id=f"{config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-thermostat_entity",
|
|
||||||
)
|
|
||||||
|
|
||||||
config_entry.add_update_listener(options_updated)
|
config_entry.add_update_listener(options_updated)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -8,9 +8,8 @@ from homeassistant.components.opentherm_gw.const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
OpenThermDeviceIdentifier,
|
OpenThermDeviceIdentifier,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_ID
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .conftest import MOCK_GATEWAY_ID, VERSION_TEST
|
from .conftest import MOCK_GATEWAY_ID, VERSION_TEST
|
||||||
|
|
||||||
@ -69,29 +68,3 @@ async def test_device_registry_update(
|
|||||||
)
|
)
|
||||||
assert gw_dev is not None
|
assert gw_dev is not None
|
||||||
assert gw_dev.sw_version == VERSION_NEW
|
assert gw_dev.sw_version == VERSION_NEW
|
||||||
|
|
||||||
|
|
||||||
# Entity migration test can be removed in 2025.4.0
|
|
||||||
async def test_climate_entity_migration(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
entity_registry: er.EntityRegistry,
|
|
||||||
mock_config_entry: MockConfigEntry,
|
|
||||||
mock_pyotgw: MagicMock,
|
|
||||||
) -> None:
|
|
||||||
"""Test that the climate entity unique_id gets migrated correctly."""
|
|
||||||
mock_config_entry.add_to_hass(hass)
|
|
||||||
entry = entity_registry.async_get_or_create(
|
|
||||||
domain="climate",
|
|
||||||
platform="opentherm_gw",
|
|
||||||
unique_id=mock_config_entry.data[CONF_ID],
|
|
||||||
)
|
|
||||||
|
|
||||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
updated_entry = entity_registry.async_get(entry.entity_id)
|
|
||||||
assert updated_entry is not None
|
|
||||||
assert (
|
|
||||||
updated_entry.unique_id
|
|
||||||
== f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-thermostat_entity"
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user