1 """Config flow for NFAndroidTV integration."""
3 from __future__
import annotations
8 from notifications_android_tv.notifications
import ConnectError, Notifications
9 import voluptuous
as vol
14 from .const
import DEFAULT_NAME, DOMAIN
16 _LOGGER = logging.getLogger(__name__)
20 """Handle a config flow for NFAndroidTV."""
23 self, user_input: dict[str, Any] |
None =
None
24 ) -> ConfigFlowResult:
25 """Handle a flow initiated by the user."""
28 if user_input
is not None:
30 {CONF_HOST: user_input[CONF_HOST], CONF_NAME: user_input[CONF_NAME]}
32 if not (error := await self._async_try_connect(user_input[CONF_HOST])):
34 title=user_input[CONF_NAME],
37 errors[
"base"] = error
41 data_schema=vol.Schema(
43 vol.Required(CONF_HOST): str,
44 vol.Required(CONF_NAME, default=DEFAULT_NAME): str,
51 """Try connecting to Android TV / Fire TV."""
53 await self.hass.async_add_executor_job(Notifications, host)
55 _LOGGER.error(
"Error connecting to device at %s", host)
56 return "cannot_connect"
58 _LOGGER.exception(
"Unexpected exception")
ConfigFlowResult async_step_user(self, dict[str, Any]|None 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)
tuple[str|None, nextcord.AppInfo|None] _async_try_connect(str token)