mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Remove opentherm_gw options migration (#125046)
This commit is contained in:
parent
436ac72b82
commit
d827c53a85
@ -46,8 +46,6 @@ from .const import (
|
|||||||
CONF_CLIMATE,
|
CONF_CLIMATE,
|
||||||
CONF_FLOOR_TEMP,
|
CONF_FLOOR_TEMP,
|
||||||
CONF_PRECISION,
|
CONF_PRECISION,
|
||||||
CONF_READ_PRECISION,
|
|
||||||
CONF_SET_PRECISION,
|
|
||||||
CONNECTION_TIMEOUT,
|
CONNECTION_TIMEOUT,
|
||||||
DATA_GATEWAYS,
|
DATA_GATEWAYS,
|
||||||
DATA_OPENTHERM_GW,
|
DATA_OPENTHERM_GW,
|
||||||
@ -109,17 +107,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
|
||||||
|
|
||||||
if config_entry.options.get(CONF_PRECISION):
|
|
||||||
migrate_options = dict(config_entry.options)
|
|
||||||
migrate_options.update(
|
|
||||||
{
|
|
||||||
CONF_READ_PRECISION: config_entry.options[CONF_PRECISION],
|
|
||||||
CONF_SET_PRECISION: config_entry.options[CONF_PRECISION],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
del migrate_options[CONF_PRECISION]
|
|
||||||
hass.config_entries.async_update_entry(config_entry, options=migrate_options)
|
|
||||||
|
|
||||||
# Migration can be removed in 2025.4.0
|
# Migration can be removed in 2025.4.0
|
||||||
dev_reg = dr.async_get(hass)
|
dev_reg = dr.async_get(hass)
|
||||||
if (
|
if (
|
||||||
|
@ -8,7 +8,6 @@ from serial import SerialException
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.opentherm_gw.const import (
|
from homeassistant.components.opentherm_gw.const import (
|
||||||
CONF_FLOOR_TEMP,
|
CONF_FLOOR_TEMP,
|
||||||
CONF_PRECISION,
|
|
||||||
CONF_READ_PRECISION,
|
CONF_READ_PRECISION,
|
||||||
CONF_SET_PRECISION,
|
CONF_SET_PRECISION,
|
||||||
CONF_TEMPORARY_OVRD_MODE,
|
CONF_TEMPORARY_OVRD_MODE,
|
||||||
@ -204,58 +203,6 @@ async def test_form_connection_error(hass: HomeAssistant) -> None:
|
|||||||
assert len(mock_connect.mock_calls) == 1
|
assert len(mock_connect.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_options_migration(hass: HomeAssistant) -> None:
|
|
||||||
"""Test migration of precision option after update."""
|
|
||||||
entry = MockConfigEntry(
|
|
||||||
domain=DOMAIN,
|
|
||||||
title="Mock Gateway",
|
|
||||||
data={
|
|
||||||
CONF_NAME: "Test Entry 1",
|
|
||||||
CONF_DEVICE: "/dev/ttyUSB0",
|
|
||||||
CONF_ID: "test_entry_1",
|
|
||||||
},
|
|
||||||
options={
|
|
||||||
CONF_FLOOR_TEMP: True,
|
|
||||||
CONF_PRECISION: PRECISION_TENTHS,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch(
|
|
||||||
"homeassistant.components.opentherm_gw.OpenThermGatewayHub.connect_and_subscribe",
|
|
||||||
return_value=True,
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"homeassistant.components.opentherm_gw.async_setup",
|
|
||||||
return_value=True,
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"pyotgw.status.StatusManager._process_updates",
|
|
||||||
return_value=None,
|
|
||||||
),
|
|
||||||
):
|
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(
|
|
||||||
entry.entry_id, context={"source": config_entries.SOURCE_USER}, data=None
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "init"
|
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
|
||||||
result["flow_id"],
|
|
||||||
user_input={},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
|
||||||
assert result["data"][CONF_READ_PRECISION] == PRECISION_TENTHS
|
|
||||||
assert result["data"][CONF_SET_PRECISION] == PRECISION_TENTHS
|
|
||||||
assert result["data"][CONF_FLOOR_TEMP] is True
|
|
||||||
|
|
||||||
|
|
||||||
async def test_options_form(hass: HomeAssistant) -> None:
|
async def test_options_form(hass: HomeAssistant) -> None:
|
||||||
"""Test the options form."""
|
"""Test the options form."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user