2021-02-24 08:34:27 +00:00
|
|
|
"""Config flow for ClimaCell integration."""
|
2021-03-17 22:43:55 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from typing import Any
|
2021-02-24 08:34:27 +00:00
|
|
|
|
|
|
|
import voluptuous as vol
|
|
|
|
|
2022-03-19 07:42:22 +00:00
|
|
|
from homeassistant import config_entries
|
|
|
|
from homeassistant.core import callback
|
2021-04-29 11:40:51 +00:00
|
|
|
from homeassistant.data_entry_flow import FlowResult
|
2021-02-24 08:34:27 +00:00
|
|
|
|
2022-03-19 07:42:22 +00:00
|
|
|
from .const import CONF_TIMESTEP, DEFAULT_TIMESTEP, DOMAIN
|
2021-02-24 08:34:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClimaCellOptionsConfigFlow(config_entries.OptionsFlow):
|
|
|
|
"""Handle ClimaCell options."""
|
|
|
|
|
|
|
|
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
|
|
|
"""Initialize ClimaCell options flow."""
|
|
|
|
self._config_entry = config_entry
|
|
|
|
|
2022-08-13 16:46:34 +00:00
|
|
|
async def async_step_init(
|
|
|
|
self, user_input: dict[str, Any] | None = None
|
|
|
|
) -> FlowResult:
|
2021-02-24 08:34:27 +00:00
|
|
|
"""Manage the ClimaCell options."""
|
|
|
|
if user_input is not None:
|
|
|
|
return self.async_create_entry(title="", data=user_input)
|
|
|
|
|
|
|
|
options_schema = {
|
|
|
|
vol.Required(
|
|
|
|
CONF_TIMESTEP,
|
|
|
|
default=self._config_entry.options.get(CONF_TIMESTEP, DEFAULT_TIMESTEP),
|
2021-04-05 17:39:39 +00:00
|
|
|
): vol.In([1, 5, 15, 30]),
|
2021-02-24 08:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self.async_show_form(
|
|
|
|
step_id="init", data_schema=vol.Schema(options_schema)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ClimaCellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
|
|
"""Handle a config flow for ClimaCell Weather API."""
|
|
|
|
|
|
|
|
VERSION = 1
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@callback
|
|
|
|
def async_get_options_flow(
|
|
|
|
config_entry: config_entries.ConfigEntry,
|
|
|
|
) -> ClimaCellOptionsConfigFlow:
|
|
|
|
"""Get the options flow for this handler."""
|
|
|
|
return ClimaCellOptionsConfigFlow(config_entry)
|