"""Repair flow fglair: key_mismatch → подсказка и reload записи. Issue не удаляем молча: подтверждение перезагружает ConfigEntry, и если ключ всё ещё неверен, coordinator создаёт issue заново (issue снимается только когда сессия выходит из key_error). """ from __future__ import annotations from typing import Any import voluptuous as vol from homeassistant.components.repairs import RepairsFlow from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResult class KeyMismatchRepairFlow(RepairsFlow): async def async_step_init( self, user_input: dict[str, Any] | None = None ) -> FlowResult: return await self.async_step_confirm() async def async_step_confirm( self, user_input: dict[str, Any] | None = None ) -> FlowResult: if user_input is not None: entry_id = (self.data or {}).get("entry_id") if entry_id: self.hass.config_entries.async_schedule_reload(entry_id) return self.async_create_entry(data={}) return self.async_show_form( step_id="confirm", data_schema=vol.Schema({}), description_placeholders=self._placeholders(), ) def _placeholders(self) -> dict[str, str]: from homeassistant.helpers import issue_registry as ir issue = ir.async_get(self.hass).async_get_issue( self.handler, self.issue_id ) return dict(issue.translation_placeholders or {}) if issue else {} async def async_create_fix_flow( hass: HomeAssistant, issue_id: str, data: dict[str, Any] | None ) -> KeyMismatchRepairFlow: return KeyMismatchRepairFlow()