34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Config flow for Sternwarte."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import voluptuous as vol
|
|
|
|
from homeassistant import config_entries
|
|
from homeassistant.data_entry_flow import FlowResult
|
|
|
|
from .const import CONF_HOST, CONF_PASSWORD, CONF_PORT, DEFAULT_HOST, DEFAULT_NAME, DEFAULT_PASSWORD, DEFAULT_PORT, DOMAIN
|
|
|
|
|
|
class SternwarteConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
"""Handle a config flow for Sternwarte."""
|
|
|
|
VERSION = 1
|
|
|
|
async def async_step_user(self, user_input: dict | None = None) -> FlowResult:
|
|
"""Handle the initial step."""
|
|
if user_input is not None:
|
|
await self.async_set_unique_id(user_input[CONF_HOST])
|
|
self._abort_if_unique_id_configured()
|
|
return self.async_create_entry(title=DEFAULT_NAME, data=user_input)
|
|
|
|
schema = vol.Schema(
|
|
{
|
|
vol.Required(CONF_HOST, default=DEFAULT_HOST): str,
|
|
vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
|
|
vol.Required(CONF_PASSWORD, default=DEFAULT_PASSWORD): str,
|
|
}
|
|
)
|
|
return self.async_show_form(step_id="user", data_schema=schema)
|
|
|