1 """Snapcast config flow."""
3 from __future__
import annotations
8 import snapcast.control
9 from snapcast.control.server
import CONTROL_PORT
10 import voluptuous
as vol
15 from .const
import DEFAULT_TITLE, DOMAIN
17 _LOGGER = logging.getLogger(__name__)
19 SNAPCAST_SCHEMA = vol.Schema(
21 vol.Required(CONF_HOST): str,
22 vol.Required(CONF_PORT, default=CONTROL_PORT): int,
28 """Snapcast config flow."""
31 """Handle first step."""
35 host = user_input[CONF_HOST]
36 port = user_input[CONF_PORT]
40 client = await snapcast.control.create_server(
41 self.hass.loop, host, port, reconnect=
False
43 except socket.gaierror:
44 errors[
"base"] =
"invalid_host"
46 errors[
"base"] =
"cannot_connect"
51 step_id=
"user", data_schema=SNAPCAST_SCHEMA, errors=errors
ConfigFlowResult async_step_user(self, user_input=None)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
None _async_abort_entries_match(self, dict[str, Any]|None match_dict=None)
ConfigFlowResult async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)