1 """Config flow to configure the WLED integration."""
3 from __future__
import annotations
7 import voluptuous
as vol
8 from wled
import WLED, Device, WLEDConnectionError
21 from .const
import CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT, DOMAIN
25 """Handle a WLED config flow."""
29 discovered_device: Device
34 config_entry: ConfigEntry,
35 ) -> WLEDOptionsFlowHandler:
36 """Get the options flow for this handler."""
40 self, user_input: dict[str, Any] |
None =
None
41 ) -> ConfigFlowResult:
42 """Handle a flow initiated by the user."""
45 if user_input
is not None:
48 except WLEDConnectionError:
49 errors[
"base"] =
"cannot_connect"
52 device.info.mac_address, raise_on_progress=
False
55 updates={CONF_HOST: user_input[CONF_HOST]}
58 title=device.info.name,
60 CONF_HOST: user_input[CONF_HOST],
66 data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
71 self, discovery_info: zeroconf.ZeroconfServiceInfo
72 ) -> ConfigFlowResult:
73 """Handle zeroconf discovery."""
75 if mac := discovery_info.properties.get(CONF_MAC):
78 updates={CONF_HOST: discovery_info.host}
84 except WLEDConnectionError:
92 "title_placeholders": {
"name": self.
discovered_devicediscovered_device.info.name},
93 "configuration_url": f
"http://{discovery_info.host}",
99 self, user_input: dict[str, Any] |
None =
None
100 ) -> ConfigFlowResult:
101 """Handle a flow initiated by zeroconf."""
102 if user_input
is not None or not onboarding.async_is_onboarded(self.hass):
111 step_id=
"zeroconf_confirm",
112 description_placeholders={
"name": self.
discovered_devicediscovered_device.info.name},
116 """Get device information from WLED device."""
118 wled = WLED(host, session=session)
119 return await wled.update()
123 """Handle WLED options."""
126 self, user_input: dict[str, Any] |
None =
None
127 ) -> ConfigFlowResult:
128 """Manage WLED options."""
129 if user_input
is not None:
134 data_schema=vol.Schema(
137 CONF_KEEP_MAIN_LIGHT,
139 CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT
Device _async_get_device(self, str host)
ConfigFlowResult async_step_zeroconf(self, zeroconf.ZeroconfServiceInfo discovery_info)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
WLEDOptionsFlowHandler async_get_options_flow(ConfigEntry config_entry)
ConfigFlowResult async_step_zeroconf_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_init(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)
ConfigEntry config_entry(self)
None config_entry(self, ConfigEntry value)
_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)
IssData update(pyiss.ISS iss)
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)