1 """Adds config flow for Mill integration."""
6 from mill_local
import Mill
as MillLocal
7 import voluptuous
as vol
13 from .const
import CLOUD, CONNECTION_TYPE, DOMAIN, LOCAL
17 """Handle a config flow for Mill integration."""
22 self, user_input: dict[str, Any] |
None =
None
23 ) -> ConfigFlowResult:
24 """Handle the initial step."""
25 data_schema = vol.Schema(
27 vol.Required(CONNECTION_TYPE, default=CLOUD): vol.In(
36 if user_input
is None:
39 data_schema=data_schema,
42 if user_input[CONNECTION_TYPE] == LOCAL:
47 self, user_input: dict[str, str] |
None =
None
48 ) -> ConfigFlowResult:
49 """Handle the local step."""
50 data_schema = vol.Schema({vol.Required(CONF_IP_ADDRESS): str})
51 if user_input
is None:
54 data_schema=data_schema,
57 mill_data_connection = MillLocal(
58 user_input[CONF_IP_ADDRESS],
65 if not await mill_data_connection.connect():
68 data_schema=data_schema,
69 errors={
"base":
"cannot_connect"},
73 title=user_input[CONF_IP_ADDRESS],
75 CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS],
76 CONNECTION_TYPE: LOCAL,
81 self, user_input: dict[str, str] |
None =
None
82 ) -> ConfigFlowResult:
83 """Handle the cloud step."""
84 data_schema = vol.Schema(
85 {vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
87 if user_input
is None:
90 data_schema=data_schema,
94 username = user_input[CONF_USERNAME].replace(
" ",
"")
95 password = user_input[CONF_PASSWORD].replace(
" ",
"")
97 mill_data_connection = Mill(
105 if not await mill_data_connection.connect():
106 errors[
"base"] =
"cannot_connect"
109 data_schema=data_schema,
121 CONF_USERNAME: username,
122 CONF_PASSWORD: password,
123 CONNECTION_TYPE: CLOUD,
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_cloud(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_local(self, dict[str, str]|None user_input=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
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_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)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)