Home Assistant Unofficial Reference 2024.12.1
repairs.py
Go to the documentation of this file.
1 """Repairs for DoorBird."""
2 
3 from __future__ import annotations
4 
5 import voluptuous as vol
6 
7 from homeassistant import data_entry_flow
8 from homeassistant.components.repairs import RepairsFlow
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers import issue_registry as ir
11 
12 
14  """Handler to show doorbird error and reload."""
15 
16  def __init__(self, entry_id: str) -> None:
17  """Initialize the flow."""
18  self.entry_identry_id = entry_id
19 
20  async def async_step_init(
21  self, user_input: dict[str, str] | None = None
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
29  """Handle the confirm step of a fix flow."""
30  if user_input is not None:
31  self.hass.config_entries.async_schedule_reload(self.entry_identry_id)
32  return self.async_create_entry(data={})
33 
34  issue_registry = ir.async_get(self.hass)
35  description_placeholders = None
36  if issue := issue_registry.async_get_issue(self.handler, self.issue_id):
37  description_placeholders = issue.translation_placeholders
38 
39  return self.async_show_form(
40  step_id="confirm",
41  data_schema=vol.Schema({}),
42  description_placeholders=description_placeholders,
43  )
44 
45 
47  hass: HomeAssistant,
48  issue_id: str,
49  data: dict[str, str | int | float | None] | None,
50 ) -> RepairsFlow:
51  """Create flow."""
52  assert data is not None
53  entry_id = data["entry_id"]
54  assert isinstance(entry_id, str)
55  return DoorBirdReloadConfirmRepairFlow(entry_id=entry_id)
data_entry_flow.FlowResult async_step_confirm(self, dict[str, str]|None user_input=None)
Definition: repairs.py:28
data_entry_flow.FlowResult async_step_init(self, dict[str, str]|None user_input=None)
Definition: repairs.py:22
RepairsFlow async_create_fix_flow(HomeAssistant hass, str issue_id, dict[str, str|int|float|None]|None data)
Definition: repairs.py:50