1 """Config flow for the jvc_projector integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from jvcprojector
import JvcProjector, JvcProjectorAuthError, JvcProjectorConnectError
9 from jvcprojector.projector
import DEFAULT_PORT
10 import voluptuous
as vol
17 from .const
import DOMAIN, NAME
21 """Config flow for the JVC Projector integration."""
26 self, user_input: dict[str, Any] |
None =
None
27 ) -> ConfigFlowResult:
28 """Handle user initiated device additions."""
31 if user_input
is not None:
32 host = user_input[CONF_HOST]
33 port = user_input[CONF_PORT]
34 password = user_input.get(CONF_PASSWORD)
42 errors[
"base"] =
"invalid_host"
43 except JvcProjectorConnectError:
44 errors[
"base"] =
"cannot_connect"
45 except JvcProjectorAuthError:
46 errors[
"base"] =
"invalid_auth"
50 updates={CONF_HOST: host, CONF_PORT: port, CONF_PASSWORD: password}
58 CONF_PASSWORD: password,
64 data_schema=vol.Schema(
66 vol.Required(CONF_HOST): str,
67 vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
68 vol.Optional(CONF_PASSWORD): str,
75 self, entry_data: Mapping[str, Any]
76 ) -> ConfigFlowResult:
77 """Perform reauth on password authentication error."""
81 self, user_input: Mapping[str, Any] |
None =
None
82 ) -> ConfigFlowResult:
83 """Dialog that informs the user that reauth is required."""
86 if user_input
is not None:
88 host = reauth_entry.data[CONF_HOST]
89 port = reauth_entry.data[CONF_PORT]
90 password = user_input[CONF_PASSWORD]
94 except JvcProjectorConnectError:
95 errors[
"base"] =
"cannot_connect"
96 except JvcProjectorAuthError:
97 errors[
"base"] =
"invalid_auth"
100 reauth_entry, data_updates=user_input
104 step_id=
"reauth_confirm",
105 data_schema=vol.Schema({vol.Optional(CONF_PASSWORD): str}),
111 """Error indicating invalid network host."""
115 """Get device mac address for config flow."""
116 device = JvcProjector(host, port=port, password=password)
118 await device.connect(
True)
120 await device.disconnect()
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth_confirm(self, Mapping[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry _get_reauth_entry(self)
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
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)
ConfigFlowResult async_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
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)
str get_mac_address(str host, int port, str|None password)
bool is_host_valid(str host)