Skip to content

Commit

Permalink
Merge pull request #343 from bruxy70/development
Browse files Browse the repository at this point in the history
#342 - Fix configuration for every-n-days
  • Loading branch information
bruxy70 authored Feb 8, 2022
2 parents 37a3c15 + b09a66e commit 2871ec3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions custom_components/garbage_collection/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def step1_frequency(self, user_input: Dict, options=False):
const.time_text(user_input.get(const.CONF_EXPIRE_AFTER))
except vol.Invalid:
self.errors["base"] = "time"
if self.errors == {}:
if not self.errors:
self.update_data(user_input)
return True
self.data_schema = OrderedDict()
Expand All @@ -119,10 +119,14 @@ def step2_detail(self, user_input: Dict):
self.errors = {}
self.data_schema = {}
if user_input is not None and user_input != {}:
# TO DO: Checking, converting (is group still gonna work?)
# Checking: mandatory fields for specific frequencies
self.update_data(user_input)
return True
if user_input.get(const.CONF_FREQUENCY) in const.DAILY_FREQUENCY:
try:
cv.date(user_input.get(const.CONF_FIRST_DATE, ""))
except vol.Invalid:
self.errors["base"] = "date"
if not self.errors:
self.update_data(user_input)
return True
self.data_schema = OrderedDict()
if self._data[const.CONF_FREQUENCY] in const.ANNUAL_FREQUENCY:
self.data_schema[self.required(const.CONF_DATE, user_input)] = str
Expand Down Expand Up @@ -162,9 +166,7 @@ def step2_detail(self, user_input: Dict):
self.required(const.CONF_FIRST_WEEK, user_input)
] = vol.All(vol.Coerce(int), vol.Range(min=1, max=52))
if self._data[const.CONF_FREQUENCY] in const.DAILY_FREQUENCY:
self.data_schema[
self.required(const.CONF_FIRST_DATE, user_input)
] = cv.date
self.data_schema[self.required(const.CONF_FIRST_DATE, user_input)] = str
if self._data.get(const.CONF_VERBOSE_STATE, False):
self.data_schema[
self.required(const.CONF_VERBOSE_FORMAT, user_input)
Expand Down Expand Up @@ -262,7 +264,7 @@ async def async_step_import(self, user_input): # pylint: disable=unused-argumen
_LOGGER.debug("Updated data config for week_order_number")
else:
user_input[const.CONF_FORCE_WEEK_NUMBERS] = False
if removed_data != {}:
if removed_data:
_LOGGER.error(
"Removed obsolete config values: %s. "
"Please check the documentation how to configure the functionality.",
Expand Down

0 comments on commit 2871ec3

Please sign in to comment.