From e676cbe9f2be1e4712348ef0656a587af143023d Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sun, 21 May 2023 10:13:36 +0200 Subject: [PATCH] Fix import issue in Workday (#92727) * Workday fix import * Messages --- .../components/workday/config_flow.py | 19 +++++++++++++++++-- homeassistant/components/workday/strings.json | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/workday/config_flow.py b/homeassistant/components/workday/config_flow.py index a66d965a351..c440ca5d73e 100644 --- a/homeassistant/components/workday/config_flow.py +++ b/homeassistant/components/workday/config_flow.py @@ -40,6 +40,7 @@ from .const import ( DEFAULT_OFFSET, DEFAULT_WORKDAYS, DOMAIN, + LOGGER, ) NONE_SENTINEL = "none" @@ -168,8 +169,17 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN): } 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( @@ -217,9 +227,12 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN): CONF_REMOVE_HOLIDAYS: combined_input[CONF_REMOVE_HOLIDAYS], CONF_PROVINCE: combined_input[CONF_PROVINCE], } - + LOGGER.debug("abort_check in options with %s", combined_input) self._async_abort_entries_match(abort_match) + + LOGGER.debug("Errors have occurred %s", errors) if not errors: + LOGGER.debug("No duplicate, no errors, creating entry") return self.async_create_entry( title=combined_input[CONF_NAME], data={}, @@ -234,6 +247,7 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN): step_id="options", data_schema=new_schema, errors=errors, + description_placeholders={"name": self.data[CONF_NAME]}, ) @@ -260,6 +274,7 @@ class WorkdayOptionsFlowHandler(OptionsFlowWithConfigEntry): except RemoveDatesError: errors["remove_holidays"] = "remove_holiday_error" else: + LOGGER.debug("abort_check in options with %s", combined_input) try: self._async_abort_entries_match( { @@ -284,7 +299,7 @@ class WorkdayOptionsFlowHandler(OptionsFlowWithConfigEntry): new_schema = self.add_suggested_values_to_schema( schema, user_input or self.options ) - + LOGGER.debug("Errors have occurred in options %s", errors) return self.async_show_form( step_id="init", data_schema=new_schema, diff --git a/homeassistant/components/workday/strings.json b/homeassistant/components/workday/strings.json index 8a516602b56..b81e027bb05 100644 --- a/homeassistant/components/workday/strings.json +++ b/homeassistant/components/workday/strings.json @@ -2,7 +2,7 @@ "config": { "abort": { "incorrect_province": "Incorrect subdivision from yaml import", - "already_configured": "[%key:common::config_flow::abort::already_configured_service%]" + "already_configured": "Workday has already been setup with chosen configuration" }, "step": { "user": { @@ -12,6 +12,7 @@ } }, "options": { + "description": "Set workday options for {name}", "data": { "excludes": "Excludes", "days_offset": "Offset",