1 """Adds config flow for GIOS."""
3 from __future__
import annotations
8 from aiohttp.client_exceptions
import ClientConnectorError
9 from gios
import ApiError, Gios, InvalidSensorsDataError, NoStationError
10 import voluptuous
as vol
16 from .const
import API_TIMEOUT, CONF_STATION_ID, DOMAIN
20 """Config flow for GIOS."""
25 self, user_input: dict[str, Any] |
None =
None
26 ) -> ConfigFlowResult:
27 """Handle a flow initialized by the user."""
30 if user_input
is not None:
33 str(user_input[CONF_STATION_ID]), raise_on_progress=
False
39 async
with asyncio.timeout(API_TIMEOUT):
40 gios = Gios(user_input[CONF_STATION_ID], websession)
41 await gios.async_update()
43 assert gios.station_name
is not None
45 title=gios.station_name,
48 except (ApiError, ClientConnectorError, TimeoutError):
49 errors[
"base"] =
"cannot_connect"
50 except NoStationError:
51 errors[CONF_STATION_ID] =
"wrong_station_id"
52 except InvalidSensorsDataError:
53 errors[CONF_STATION_ID] =
"invalid_sensors_data"
57 data_schema=vol.Schema(
59 vol.Required(CONF_STATION_ID): int,
61 CONF_NAME, default=self.hass.config.location_name
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_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)