|
@@ -114,29 +114,41 @@ class RoomCalOptionsFlow(OptionsFlow):
|
|
|
|
|
|
|
|
if user_input is not None:
|
|
if user_input is not None:
|
|
|
if user_input.get(CONF_CALDAV_ENABLED) and user_input.get(CONF_CALDAV_URL):
|
|
if user_input.get(CONF_CALDAV_ENABLED) and user_input.get(CONF_CALDAV_URL):
|
|
|
|
|
+ username = user_input.pop(CONF_USERNAME, "") or self.config_entry.data.get(CONF_USERNAME, "")
|
|
|
|
|
+ password = user_input.pop(CONF_PASSWORD, "") or self.config_entry.data.get(CONF_PASSWORD, "")
|
|
|
try:
|
|
try:
|
|
|
await self.hass.async_add_executor_job(
|
|
await self.hass.async_add_executor_job(
|
|
|
_test_caldav_auth,
|
|
_test_caldav_auth,
|
|
|
user_input[CONF_CALDAV_URL],
|
|
user_input[CONF_CALDAV_URL],
|
|
|
- self.config_entry.data.get(CONF_USERNAME, ""),
|
|
|
|
|
- self.config_entry.data.get(CONF_PASSWORD, ""),
|
|
|
|
|
|
|
+ username,
|
|
|
|
|
+ password,
|
|
|
)
|
|
)
|
|
|
except caldav_error.AuthorizationError:
|
|
except caldav_error.AuthorizationError:
|
|
|
errors["base"] = "invalid_auth"
|
|
errors["base"] = "invalid_auth"
|
|
|
except Exception:
|
|
except Exception:
|
|
|
errors["base"] = "cannot_connect"
|
|
errors["base"] = "cannot_connect"
|
|
|
|
|
+ else:
|
|
|
|
|
+ await self.hass.config_entries.async_update_entry(
|
|
|
|
|
+ self.config_entry,
|
|
|
|
|
+ data={**self.config_entry.data, CONF_USERNAME: username, CONF_PASSWORD: password},
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
if not errors:
|
|
if not errors:
|
|
|
merged = {**self.config_entry.options, **user_input}
|
|
merged = {**self.config_entry.options, **user_input}
|
|
|
return self.async_create_entry(data=merged)
|
|
return self.async_create_entry(data=merged)
|
|
|
|
|
|
|
|
opts = self.config_entry.options
|
|
opts = self.config_entry.options
|
|
|
|
|
+ data = self.config_entry.data
|
|
|
return self.async_show_form(
|
|
return self.async_show_form(
|
|
|
step_id="caldav",
|
|
step_id="caldav",
|
|
|
data_schema=vol.Schema({
|
|
data_schema=vol.Schema({
|
|
|
vol.Required(CONF_CALDAV_ENABLED, default=opts.get(CONF_CALDAV_ENABLED, False)): BooleanSelector(),
|
|
vol.Required(CONF_CALDAV_ENABLED, default=opts.get(CONF_CALDAV_ENABLED, False)): BooleanSelector(),
|
|
|
vol.Optional(CONF_CALDAV_URL, default=opts.get(CONF_CALDAV_URL, "")): str,
|
|
vol.Optional(CONF_CALDAV_URL, default=opts.get(CONF_CALDAV_URL, "")): str,
|
|
|
vol.Optional(CONF_CALENDAR_NAME, default=opts.get(CONF_CALENDAR_NAME, "")): str,
|
|
vol.Optional(CONF_CALENDAR_NAME, default=opts.get(CONF_CALENDAR_NAME, "")): str,
|
|
|
|
|
+ vol.Optional(CONF_USERNAME, default=data.get(CONF_USERNAME, "")): str,
|
|
|
|
|
+ vol.Optional(CONF_PASSWORD, default=""): TextSelector(
|
|
|
|
|
+ TextSelectorConfig(type=TextSelectorType.PASSWORD)
|
|
|
|
|
+ ),
|
|
|
}),
|
|
}),
|
|
|
errors=errors,
|
|
errors=errors,
|
|
|
)
|
|
)
|