1 """Config flow for Palazzetti."""
5 from pypalazzetti.client
import PalazzettiClient
6 from pypalazzetti.exceptions
import CommunicationError
7 import voluptuous
as vol
14 from .const
import DOMAIN, LOGGER
18 """Palazzetti config flow."""
20 _discovered_device: PalazzettiClient
23 self, user_input: dict[str, Any] |
None =
None
24 ) -> ConfigFlowResult:
25 """User configuration step."""
26 errors: dict[str, str] = {}
27 if user_input
is not None:
28 host = user_input[CONF_HOST]
29 client = PalazzettiClient(hostname=host)
31 await client.connect()
32 except CommunicationError:
33 LOGGER.exception(
"Communication error")
34 errors[
"base"] =
"cannot_connect"
36 formatted_mac = dr.format_mac(client.mac)
51 data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
56 self, discovery_info: dhcp.DhcpServiceInfo
57 ) -> ConfigFlowResult:
58 """Handle DHCP discovery."""
61 "DHCP discovery detected Palazzetti: %s", discovery_info.macaddress
69 except CommunicationError:
72 return await self.async_step_discovery_confirm()
74 async
def async_step_discovery_confirm(
75 self, user_input: dict[str, Any] |
None =
None
76 ) -> ConfigFlowResult:
77 """Confirm discovery."""
78 if user_input
is not None:
86 step_id=
"discovery_confirm",
87 description_placeholders={
ConfigFlowResult async_step_user(self, dict[str, Any]|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")
None _set_confirm_only(self)
ConfigFlowResult async_step_dhcp(self, DhcpServiceInfo discovery_info)
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)
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)