1 """Config flow support for Intergas InComfort integration."""
5 from aiohttp
import ClientResponseError
6 from incomfortclient
import IncomfortError, InvalidHeaterList
7 import voluptuous
as vol
18 from .const
import DOMAIN
19 from .coordinator
import async_connect_gateway
21 TITLE =
"Intergas InComfort/Intouch Lan2RF gateway"
23 CONFIG_SCHEMA = vol.Schema(
37 ERROR_STATUS_MAPPING: dict[int, tuple[str, str]] = {
38 401: (CONF_PASSWORD,
"auth_error"),
39 404: (
"base",
"not_found"),
44 hass: HomeAssistant, config: dict[str, Any]
45 ) -> dict[str, str] |
None:
46 """Try to connect to the Lan2RF gateway."""
49 except InvalidHeaterList:
50 return {
"base":
"no_heaters"}
51 except IncomfortError
as exc:
52 if isinstance(exc.message, ClientResponseError):
53 scope, error = ERROR_STATUS_MAPPING.get(
54 exc.message.status, (
"base",
"unknown")
57 return {
"base":
"unknown"}
59 return {
"base":
"timeout_error"}
61 return {
"base":
"unknown"}
67 """Config flow to set up an Intergas InComfort boyler and thermostats."""
70 self, user_input: dict[str, Any] |
None =
None
71 ) -> ConfigFlowResult:
72 """Handle the initial step."""
73 errors: dict[str, str] |
None =
None
74 if user_input
is not None:
82 step_id=
"user", data_schema=CONFIG_SCHEMA, errors=errors
85 async
def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
86 """Import `incomfort` config entry from configuration.yaml."""
87 errors: dict[str, str] |
None =
None
90 reason = next(iter(errors.items()))[1]
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
dict[str, str]|None async_try_connect_gateway(HomeAssistant hass, dict[str, Any] config)
InComfortData async_connect_gateway(HomeAssistant hass, dict[str, Any] entry_data)
config_entries.ConfigFlowResult async_step_import(self, dict[str, Any]|None _)