Skip to content

Commit

Permalink
Fix yearly calculation after resetting chore date to blank
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcclure committed Apr 16, 2023
1 parent 3c21261 commit 9117123
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions custom_components/chore_helper/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ async def _validate_config(
data[const.CONF_DAY_OF_MONTH] = None

if const.CONF_DATE in data:
if data[const.CONF_DATE] == "0" or data[const.CONF_DATE] == "0/0":
data[const.CONF_DATE] = ""
if (
data[const.CONF_DATE] == "0"
or data[const.CONF_DATE] == "0/0"
or data[const.CONF_DATE] == ""
):
data[const.CONF_DATE] = None
else:
try:
helpers.month_day_text(data[const.CONF_DATE])
Expand Down
2 changes: 1 addition & 1 deletion custom_components/chore_helper/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def _find_candidate_date(self, day1: date) -> date | None:
start_date = self._calculate_schedule_start_date()
day1 = self.calculate_day1(day1, start_date)
conf_date = self._date
if conf_date is None:
if conf_date is None or conf_date == "":
conf_date = start_date
else:
conf_date = datetime.strptime(conf_date, "%m/%d")
Expand Down

0 comments on commit 9117123

Please sign in to comment.