1 """Adds config flow for Dune HD integration."""
3 from __future__
import annotations
7 from pdunehd
import DuneHDPlayer
8 import voluptuous
as vol
15 from .const
import DOMAIN
19 """Handle a config flow for Dune HD integration."""
24 """Initialize Dune HD player."""
25 player = DuneHDPlayer(host)
26 state = await self.hass.async_add_executor_job(player.update_state)
31 self, user_input: dict[str, Any] |
None =
None
32 ) -> ConfigFlowResult:
33 """Handle the initial step."""
36 if user_input
is not None:
38 host: str = user_input[CONF_HOST]
42 raise AlreadyConfigured
45 errors[CONF_HOST] =
"cannot_connect"
46 except AlreadyConfigured:
47 errors[CONF_HOST] =
"already_configured"
51 errors[CONF_HOST] =
"invalid_host"
55 data_schema=vol.Schema({vol.Required(CONF_HOST, default=
""): str}),
60 """See if we already have a dunehd entry matching user input configured."""
64 return host
in existing_hosts
68 """Error to indicate we cannot connect."""
72 """Error to indicate device is already configured."""
bool host_already_configured(self, str host)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
None init_device(self, str host)
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)
list[ConfigEntry] _async_current_entries(self, bool|None include_ignore=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)
bool is_host_valid(str host)