From 6f64c36073153c963af65637a0fe17c5b05fee60 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 13 May 2026 20:14:35 +0000 Subject: [PATCH] Mods --- homeassistant/components/min_max/__init__.py | 1 + tests/components/min_max/test_init.py | 56 +++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/min_max/__init__.py b/homeassistant/components/min_max/__init__.py index 75121b070696..3a64644c7365 100644 --- a/homeassistant/components/min_max/__init__.py +++ b/homeassistant/components/min_max/__init__.py @@ -16,6 +16,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass, DOMAIN, f"migrate_to_group_sensor-{entry.entry_id}", + breaks_in_ha_version="2026.12.0", is_fixable=True, is_persistent=False, severity=IssueSeverity.WARNING, diff --git a/tests/components/min_max/test_init.py b/tests/components/min_max/test_init.py index 364ff49ab04a..e781da2d0a3b 100644 --- a/tests/components/min_max/test_init.py +++ b/tests/components/min_max/test_init.py @@ -7,18 +7,26 @@ from syrupy.filters import props from homeassistant.components.group import DOMAIN as GROUP_DOMAIN from homeassistant.components.min_max.const import DOMAIN from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er +from homeassistant.data_entry_flow import FlowResultType +from homeassistant.helpers import entity_registry as er, issue_registry as ir +from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry, async_fire_time_changed +from tests.components.repairs import process_repair_fix_flow, start_repair_fix_flow +from tests.typing import ClientSessionGenerator, WebSocketGenerator async def test_setup_migrates_to_groups( hass: HomeAssistant, entity_registry: er.EntityRegistry, + issue_registry: ir.IssueRegistry, freezer: FrozenDateTimeFactory, snapshot: SnapshotAssertion, + hass_client: ClientSessionGenerator, + hass_ws_client: WebSocketGenerator, ) -> None: """Test setting up and removing a config entry.""" + assert await async_setup_component(hass, "repairs", {}) hass.states.async_set("sensor.input_one", "10") hass.states.async_set("sensor.input_two", "20") @@ -30,6 +38,7 @@ async def test_setup_migrates_to_groups( config_entry = MockConfigEntry( data={}, domain=DOMAIN, + entry_id="123", options={ "entity_ids": input_sensors, "name": "My min_max", @@ -40,13 +49,42 @@ async def test_setup_migrates_to_groups( ) config_entry.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done(wait_background_tasks=True) + await hass.async_block_till_done() # Check the entity is registered in the entity registry entity = entity_registry.async_get(min_max_entity_id) assert entity is not None + + issue = issue_registry.async_get_issue( + DOMAIN, f"migrate_to_group_sensor-{config_entry.entry_id}" + ) + assert issue is not None + assert issue.is_fixable is True + assert issue.breaks_in_ha_version == "2026.12.0" + + ws_client = await hass_ws_client(hass) + client = await hass_client() + await ws_client.send_json({"id": 1, "type": "repairs/list_issues"}) + msg = await ws_client.receive_json() + + assert msg["success"] + + data = await start_repair_fix_flow( + client, DOMAIN, f"migrate_to_group_sensor-{config_entry.entry_id}" + ) + flow_id = data["flow_id"] + assert data["description_placeholders"] == {"title": "My min_max"} + assert data["step_id"] == "migrate" + + data = await process_repair_fix_flow(client, flow_id, json={}) + + assert data["type"] == FlowResultType.CREATE_ENTRY + await hass.async_block_till_done() + + entity = entity_registry.async_get(min_max_entity_id) assert entity.config_entry_id is not None assert entity.config_entry_id != config_entry.entry_id + assert entity.unique_id != config_entry.entry_id assert entity.platform == GROUP_DOMAIN # Check the platform is setup correctly @@ -54,15 +92,19 @@ async def test_setup_migrates_to_groups( state = hass.states.get(min_max_entity_id) assert state.state == "20.0" + # Assert min/max config entry is removed + min_max_config_entries = hass.config_entries.async_entries(DOMAIN) + assert len(min_max_config_entries) == 0 + config_entry = hass.config_entries.async_entries("group")[0] assert config_entry.as_dict() == snapshot( exclude=props("created_at", "entry_id", "modified_at") ) - config_entry_min_max = hass.config_entries.async_entries(DOMAIN)[0] - assert config_entry_min_max + + hass.states.async_set("sensor.input_two", "30") freezer.tick(60 * 5) async_fire_time_changed(hass) - await hass.async_block_till_done(wait_background_tasks=True) - config_entry_min_max = hass.config_entries.async_entries(DOMAIN) - assert not config_entry_min_max + await hass.async_block_till_done() + state = hass.states.get(min_max_entity_id) + assert state.state == "30.0"