Revert "Remove Workday YAML configuration (#94102)" (#95524)

This commit is contained in:
Franck Nijhof 2023-06-29 12:00:13 +02:00 committed by GitHub
parent ed16fffa79
commit 34ac541493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 297 additions and 2 deletions

View file

@ -155,6 +155,33 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN):
"""Get the options flow for this handler."""
return WorkdayOptionsFlowHandler(config_entry)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
"""Import a configuration from config.yaml."""
abort_match = {
CONF_COUNTRY: config[CONF_COUNTRY],
CONF_EXCLUDES: config[CONF_EXCLUDES],
CONF_OFFSET: config[CONF_OFFSET],
CONF_WORKDAYS: config[CONF_WORKDAYS],
CONF_ADD_HOLIDAYS: config[CONF_ADD_HOLIDAYS],
CONF_REMOVE_HOLIDAYS: config[CONF_REMOVE_HOLIDAYS],
CONF_PROVINCE: config.get(CONF_PROVINCE),
}
new_config = config.copy()
new_config[CONF_PROVINCE] = config.get(CONF_PROVINCE)
LOGGER.debug("Importing with %s", new_config)
self._async_abort_entries_match(abort_match)
self.data[CONF_NAME] = config.get(CONF_NAME, DEFAULT_NAME)
self.data[CONF_COUNTRY] = config[CONF_COUNTRY]
LOGGER.debug(
"No duplicate, next step with name %s for country %s",
self.data[CONF_NAME],
self.data[CONF_COUNTRY],
)
return await self.async_step_options(user_input=new_config)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult: