Home Assistant Unofficial Reference 2024.12.1
repairs.py
Go to the documentation of this file.
1 """Repairs for the SeventeenTrack integration."""
2 
3 import voluptuous as vol
4 
5 from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
6 from homeassistant.config_entries import ConfigEntry
7 from homeassistant.core import HomeAssistant
8 from homeassistant.data_entry_flow import FlowResult
9 
10 from .const import DEPRECATED_KEY
11 
12 
14  """Handler for an issue fixing flow."""
15 
16  def __init__(self, entry: ConfigEntry) -> None:
17  """Create flow."""
18  self.entryentry = entry
19 
20  async def async_step_init(
21  self, user_input: dict[str, str] | None = None
22  ) -> FlowResult:
23  """Handle the first step of a fix flow."""
24  return await self.async_step_confirmasync_step_confirm()
25 
26  async def async_step_confirm(
27  self, user_input: dict[str, str] | None = None
28  ) -> FlowResult:
29  """Handle the confirm step of a fix flow."""
30  if user_input is not None:
31  data = {**self.entryentry.data, DEPRECATED_KEY: True}
32  self.hass.config_entries.async_update_entry(self.entryentry, data=data)
33  return self.async_create_entryasync_create_entry(data={})
34 
35  return self.async_show_formasync_show_form(
36  step_id="confirm",
37  data_schema=vol.Schema({}),
38  )
39 
40 
42  hass: HomeAssistant, issue_id: str, data: dict
43 ) -> RepairsFlow:
44  """Create flow."""
45  if issue_id.startswith("deprecate_sensor_") and (
46  entry := hass.config_entries.async_get_entry(data["entry_id"])
47  ):
48  return SensorDeprecationRepairFlow(entry)
49  return ConfirmRepairFlow()
FlowResult async_step_confirm(self, dict[str, str]|None user_input=None)
Definition: repairs.py:28
FlowResult async_step_init(self, dict[str, str]|None user_input=None)
Definition: repairs.py:22
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)
RepairsFlow async_create_fix_flow(HomeAssistant hass, str issue_id, dict data)
Definition: repairs.py:43