Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for Times of the Day integration."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Mapping
6 from typing import Any, cast
7 
8 import voluptuous as vol
9 
10 from homeassistant.const import CONF_NAME
11 from homeassistant.helpers import selector
13  SchemaConfigFlowHandler,
14  SchemaFlowFormStep,
15 )
16 
17 from .const import CONF_AFTER_TIME, CONF_BEFORE_TIME, DOMAIN
18 
19 OPTIONS_SCHEMA = vol.Schema(
20  {
21  vol.Required(CONF_AFTER_TIME): selector.TimeSelector(),
22  vol.Required(CONF_BEFORE_TIME): selector.TimeSelector(),
23  }
24 )
25 
26 CONFIG_SCHEMA = vol.Schema(
27  {
28  vol.Required(CONF_NAME): selector.TextSelector(),
29  }
30 ).extend(OPTIONS_SCHEMA.schema)
31 
32 CONFIG_FLOW = {
33  "user": SchemaFlowFormStep(CONFIG_SCHEMA),
34 }
35 
36 OPTIONS_FLOW = {
37  "init": SchemaFlowFormStep(OPTIONS_SCHEMA),
38 }
39 
40 
42  """Handle a config or options flow for Times of the Day."""
43 
44  config_flow = CONFIG_FLOW
45  options_flow = OPTIONS_FLOW
46 
47  def async_config_entry_title(self, options: Mapping[str, Any]) -> str:
48  """Return config entry title."""
49  return cast(str, options["name"])
str async_config_entry_title(self, Mapping[str, Any] options)
Definition: config_flow.py:47