1 """Config flow for tolo."""
3 from __future__
import annotations
8 from tololib
import ToloClient, ToloCommunicationError
9 import voluptuous
as vol
16 from .const
import DEFAULT_NAME, DOMAIN
18 _LOGGER = logging.getLogger(__name__)
22 """ConfigFlow for TOLO Sauna."""
30 client = ToloClient(host)
32 result = client.get_status()
33 except ToloCommunicationError:
35 return result
is not None
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle a flow initialized by the user."""
43 if user_input
is not None:
46 device_available = await self.hass.async_add_executor_job(
50 if not device_available:
51 errors[
"base"] =
"cannot_connect"
54 title=DEFAULT_NAME, data={CONF_HOST: user_input[CONF_HOST]}
59 data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
64 self, discovery_info: dhcp.DhcpServiceInfo
65 ) -> ConfigFlowResult:
66 """Handle a flow initialized by discovery."""
71 device_available = await self.hass.async_add_executor_job(
81 self, user_input: dict[str, Any] |
None =
None
82 ) -> ConfigFlowResult:
83 """Handle user-confirmation of discovered node."""
84 if user_input
is not None:
bool _check_device_availability(str host)
ConfigFlowResult async_step_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_dhcp(self, dhcp.DhcpServiceInfo discovery_info)
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_abort(self, *str reason, Mapping[str, str]|None description_placeholders=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)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)