1 """Config flow for Bose SoundTouch integration."""
5 from libsoundtouch
import soundtouch_device
6 from requests
import RequestException
7 import voluptuous
as vol
14 from .const
import DOMAIN
18 """Handle a config flow for Bose SoundTouch."""
23 """Initialize a new SoundTouch config flow."""
24 self.
hosthost: str |
None =
None
25 self.
namename: str |
None =
None
28 self, user_input: dict[str, Any] |
None =
None
29 ) -> ConfigFlowResult:
30 """Handle a flow initiated by the user."""
33 if user_input
is not None:
34 self.
hosthost = user_input[CONF_HOST]
38 except RequestException:
39 errors[
"base"] =
"cannot_connect"
46 data_schema=vol.Schema(
48 vol.Required(CONF_HOST): cv.string,
55 self, discovery_info: ZeroconfServiceInfo
56 ) -> ConfigFlowResult:
57 """Handle a flow initiated by a zeroconf discovery."""
58 self.
hosthost = discovery_info.host
62 except RequestException:
67 self.context[
"title_placeholders"] = {
"name": self.
namename}
71 self, user_input: dict[str, Any] |
None =
None
72 ) -> ConfigFlowResult:
73 """Handle user-confirmation of discovered node."""
74 if user_input
is not None:
77 step_id=
"zeroconf_confirm",
79 description_placeholders={
"name": self.
namename
or "?"},
83 """Get device ID from SoundTouch device."""
84 device = await self.hass.async_add_executor_job(soundtouch_device, self.
hosthost)
88 device.config.device_id, raise_on_progress=raise_on_progress
92 self.
namename = device.config.name
95 """Finish config flow and create a SoundTouch config entry."""
97 title=self.
namename
or "SoundTouch",
99 CONF_HOST: self.
hosthost,
ConfigFlowResult async_step_zeroconf_confirm(self, dict[str, Any]|None user_input=None)
None _async_get_device_id(self, bool raise_on_progress=True)
ConfigFlowResult async_step_zeroconf(self, ZeroconfServiceInfo discovery_info)
ConfigFlowResult _async_create_soundtouch_entry(self)
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")
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)