diff --git a/homeassistant/components/esphome/repairs.py b/homeassistant/components/esphome/repairs.py index 3cba8730cd6..d40a68dde1a 100644 --- a/homeassistant/components/esphome/repairs.py +++ b/homeassistant/components/esphome/repairs.py @@ -8,8 +8,7 @@ import voluptuous as vol from homeassistant import data_entry_flow from homeassistant.components.repairs import RepairsFlow -from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import issue_registry as ir +from homeassistant.core import HomeAssistant from .manager import async_replace_device @@ -22,13 +21,6 @@ class ESPHomeRepair(RepairsFlow): self._data = data super().__init__() - @callback - def _async_get_placeholders(self) -> dict[str, str]: - issue_registry = ir.async_get(self.hass) - issue = issue_registry.async_get_issue(self.handler, self.issue_id) - assert issue is not None - return issue.translation_placeholders or {} - class DeviceConflictRepair(ESPHomeRepair): """Handler for an issue fixing device conflict.""" @@ -58,7 +50,6 @@ class DeviceConflictRepair(ESPHomeRepair): return self.async_show_menu( step_id="init", menu_options=["migrate", "manual"], - description_placeholders=self._async_get_placeholders(), ) async def async_step_migrate( @@ -69,7 +60,6 @@ class DeviceConflictRepair(ESPHomeRepair): return self.async_show_form( step_id="migrate", data_schema=vol.Schema({}), - description_placeholders=self._async_get_placeholders(), ) entry_id = self.entry_id await async_replace_device(self.hass, entry_id, self.stored_mac, self.mac) @@ -84,7 +74,6 @@ class DeviceConflictRepair(ESPHomeRepair): return self.async_show_form( step_id="manual", data_schema=vol.Schema({}), - description_placeholders=self._async_get_placeholders(), ) self.hass.config_entries.async_schedule_reload(self.entry_id) return self.async_create_entry(data={}) diff --git a/homeassistant/components/knx/repairs.py b/homeassistant/components/knx/repairs.py index 598bdc7d0a9..37bdaaa0f42 100644 --- a/homeassistant/components/knx/repairs.py +++ b/homeassistant/components/knx/repairs.py @@ -110,13 +110,6 @@ def _data_secure_group_key_issue_handler( class DataSecureGroupIssueRepairFlow(RepairsFlow): """Handler for an issue fixing flow for outdated DataSecure keys.""" - @callback - def _async_get_placeholders(self) -> dict[str, str]: - issue_registry = ir.async_get(self.hass) - issue = issue_registry.async_get_issue(self.handler, self.issue_id) - assert issue is not None - return issue.translation_placeholders or {} - async def async_step_init( self, user_input: dict[str, str] | None = None ) -> data_entry_flow.FlowResult: @@ -157,7 +150,6 @@ class DataSecureGroupIssueRepairFlow(RepairsFlow): return self.async_show_form( step_id="secure_knxkeys", data_schema=vol.Schema(fields), - description_placeholders=self._async_get_placeholders(), errors=errors, ) diff --git a/tests/components/conftest.py b/tests/components/conftest.py index bcefe2d47c5..7dff435dc9b 100644 --- a/tests/components/conftest.py +++ b/tests/components/conftest.py @@ -811,6 +811,7 @@ async def _check_config_flow_result_translations( return key_prefix = "" + description_placeholders = result.get("description_placeholders") if isinstance(manager, ConfigEntriesFlowManager): category = "config" integration = flow.handler @@ -823,6 +824,12 @@ async def _check_config_flow_result_translations( issue_id = flow.issue_id issue = ir.async_get(flow.hass).async_get_issue(integration, issue_id) key_prefix = f"{issue.translation_key}.fix_flow." + description_placeholders = { + # Both are used in issue translations, and description_placeholders + # takes precedence over translation_placeholders + **(issue.translation_placeholders or {}), + **(description_placeholders or {}), + } else: return @@ -838,7 +845,7 @@ async def _check_config_flow_result_translations( category, integration, f"{key_prefix}step.{step_id}", - result["description_placeholders"], + description_placeholders, result["data_schema"], ignore_translations_for_mock_domains, ) @@ -852,7 +859,7 @@ async def _check_config_flow_result_translations( category, integration, f"{key_prefix}error.{error}", - result["description_placeholders"], + description_placeholders, ) return @@ -868,7 +875,7 @@ async def _check_config_flow_result_translations( category, integration, f"{key_prefix}abort.{result['reason']}", - result["description_placeholders"], + description_placeholders, ) diff --git a/tests/components/esphome/test_repairs.py b/tests/components/esphome/test_repairs.py index f64cb806950..7b83ed894bb 100644 --- a/tests/components/esphome/test_repairs.py +++ b/tests/components/esphome/test_repairs.py @@ -80,13 +80,6 @@ async def test_device_conflict_manual( data = await start_repair_fix_flow(client, DOMAIN, issue_id) flow_id = data["flow_id"] - assert data["description_placeholders"] == { - "ip": "192.168.1.2", - "mac": "11:22:33:44:55:ab", - "model": "esp32-iso-poe", - "name": "test", - "stored_mac": "11:22:33:44:55:aa", - } assert data["type"] == FlowResultType.MENU assert data["step_id"] == "init" @@ -95,13 +88,6 @@ async def test_device_conflict_manual( ) flow_id = data["flow_id"] - assert data["description_placeholders"] == { - "ip": "192.168.1.2", - "mac": "11:22:33:44:55:ab", - "model": "esp32-iso-poe", - "name": "test", - "stored_mac": "11:22:33:44:55:aa", - } assert data["type"] == FlowResultType.FORM assert data["step_id"] == "manual" @@ -198,13 +184,6 @@ async def test_device_conflict_migration( data = await start_repair_fix_flow(client, DOMAIN, issue_id) flow_id = data["flow_id"] - assert data["description_placeholders"] == { - "ip": "test.local", - "mac": "11:22:33:44:55:ab", - "model": "esp32-iso-poe", - "name": "test", - "stored_mac": "11:22:33:44:55:aa", - } assert data["type"] == FlowResultType.MENU assert data["step_id"] == "init" @@ -213,13 +192,6 @@ async def test_device_conflict_migration( ) flow_id = data["flow_id"] - assert data["description_placeholders"] == { - "ip": "test.local", - "mac": "11:22:33:44:55:ab", - "model": "esp32-iso-poe", - "name": "test", - "stored_mac": "11:22:33:44:55:aa", - } assert data["type"] == FlowResultType.FORM assert data["step_id"] == "migrate" diff --git a/tests/components/knx/test_repairs.py b/tests/components/knx/test_repairs.py index 54cc3c90e66..3ea66d9465c 100644 --- a/tests/components/knx/test_repairs.py +++ b/tests/components/knx/test_repairs.py @@ -77,14 +77,13 @@ async def test_data_secure_group_key_issue_repair_flow( knx.receive_data_secure_issue("11/0/0", source="1.0.1") knx.receive_data_secure_issue("1/2/5", source="1.0.10") knx.receive_data_secure_issue("1/2/5", source="1.0.1") - _placeholders = { - "addresses": "`1/2/5` from 1.0.1, 1.0.10\n`11/0/0` from 1.0.1", # check sorting - "interface": "0.0.0", - } issue_registry = ir.async_get(hass) issue = issue_registry.async_get_issue(DOMAIN, REPAIR_ISSUE_DATA_SECURE_GROUP_KEY) assert issue is not None - assert issue.translation_placeholders == _placeholders + assert issue.translation_placeholders == { + "addresses": "`1/2/5` from 1.0.1, 1.0.10\n`11/0/0` from 1.0.1", # check sorting + "interface": "0.0.0", + } issues = await get_repairs(hass, hass_ws_client) assert issues @@ -98,7 +97,6 @@ async def test_data_secure_group_key_issue_repair_flow( flow_id = flow["flow_id"] assert flow["type"] == FlowResultType.FORM assert flow["step_id"] == "secure_knxkeys" - assert flow["description_placeholders"] == _placeholders # test error handling with patch_file_upload(