2022-07-20 12:46:06 +00:00
|
|
|
"""Repairs platform for the demo integration."""
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
from homeassistant import data_entry_flow
|
2022-08-05 10:07:51 +00:00
|
|
|
from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
|
2022-07-20 12:46:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DemoFixFlow(RepairsFlow):
|
|
|
|
"""Handler for an issue fixing flow."""
|
|
|
|
|
|
|
|
async def async_step_init(
|
|
|
|
self, user_input: dict[str, str] | None = None
|
|
|
|
) -> data_entry_flow.FlowResult:
|
|
|
|
"""Handle the first step of a fix flow."""
|
|
|
|
|
|
|
|
return await (self.async_step_confirm())
|
|
|
|
|
|
|
|
async def async_step_confirm(
|
|
|
|
self, user_input: dict[str, str] | None = None
|
|
|
|
) -> data_entry_flow.FlowResult:
|
|
|
|
"""Handle the confirm step of a fix flow."""
|
|
|
|
if user_input is not None:
|
2022-08-05 10:07:51 +00:00
|
|
|
return self.async_create_entry(title="", data={})
|
2022-07-20 12:46:06 +00:00
|
|
|
|
|
|
|
return self.async_show_form(step_id="confirm", data_schema=vol.Schema({}))
|
|
|
|
|
|
|
|
|
|
|
|
async def async_create_fix_flow(hass, issue_id):
|
|
|
|
"""Create flow."""
|
2022-08-05 10:07:51 +00:00
|
|
|
if issue_id == "bad_psu":
|
|
|
|
# The bad_psu issue doesn't have its own flow
|
|
|
|
return ConfirmRepairFlow()
|
|
|
|
|
|
|
|
# Other issues have a custom flow
|
2022-07-20 12:46:06 +00:00
|
|
|
return DemoFixFlow()
|