Skip to content

Commit

Permalink
Add option to show overdue chores today on the calendar, instead of i…
Browse files Browse the repository at this point in the history
…n the past
  • Loading branch information
bmcclure committed May 11, 2023
1 parent 7bc46a9 commit 691aa94
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions custom_components/chore_helper/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ async def async_get_events(
continue
chore = hass.data[DOMAIN][SENSOR_PLATFORM][entity]
start = chore.get_next_due_date(start_date, True)
today = datetime.now().date()
while start is not None and start_date <= start <= end_date:
if chore.show_overdue_today and (start < today):
start = today

try:
end = start + timedelta(days=1)
except TypeError:
Expand Down
4 changes: 4 additions & 0 deletions custom_components/chore_helper/chore.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Chore(RestoreEntity):
"_offset_dates",
"_add_dates",
"_remove_dates",
"show_overdue_today",
"config_entry",
"last_completed",
)
Expand Down Expand Up @@ -79,6 +80,9 @@ def __init__(self, config_entry: ConfigEntry) -> None:
const.CONF_DATE_FORMAT, const.DEFAULT_DATE_FORMAT
)
self._forecast_dates: int = config.get(const.CONF_FORECAST_DATES) or 0
self.show_overdue_today: bool = (
config.get(const.CONF_SHOW_OVERDUE_TODAY) or False
)
self._due_dates: list[date] = []
self._next_due_date: date | None = None
self._last_updated: datetime | None = None
Expand Down
5 changes: 5 additions & 0 deletions custom_components/chore_helper/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def general_schema_definition(
),
optional(ATTR_HIDDEN, handler.options, False): bool,
optional(const.CONF_MANUAL, handler.options, False): bool,
optional(
const.CONF_SHOW_OVERDUE_TODAY,
handler.options,
const.DEFAULT_SHOW_OVERDUE_TODAY,
): bool,
}

return schema
Expand Down
2 changes: 2 additions & 0 deletions custom_components/chore_helper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CONF_SENSOR = "sensor"
CONF_ENABLED = "enabled"
CONF_FORECAST_DATES = "forecast_dates"
CONF_SHOW_OVERDUE_TODAY = "show_overdue_today"
CONF_FREQUENCY = "frequency"
CONF_MANUAL = "manual_update"
CONF_ICON_NORMAL = "icon_normal"
Expand Down Expand Up @@ -58,6 +59,7 @@
DEFAULT_FIRST_WEEK = 1
DEFAULT_DATE_FORMAT = "%b-%d-%Y"
DEFAULT_FORECAST_DATES = 10
DEFAULT_SHOW_OVERDUE_TODAY = False

DEFAULT_ICON_NORMAL = "mdi:broom"
DEFAULT_ICON_TODAY = "mdi:bell"
Expand Down
6 changes: 4 additions & 2 deletions custom_components/chore_helper/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"icon_tomorrow": "Icon due tomorrow (mdi:bell-outline) - optional",
"icon_today": "Icon due today (mdi:bell) - optional",
"icon_overdue": "Icon overdue (mdi:bell-alert) - optional",
"forecast_dates": "Number of future due dates to forecast"
"forecast_dates": "Number of future due dates to forecast",
"show_overdue_today": "Show overdue chore today on calendar"
}
},
"detail": {
Expand Down Expand Up @@ -66,7 +67,8 @@
"icon_tomorrow": "Icon due tomorrow (mdi:bell-outline) - optional",
"icon_today": "Icon due today (mdi:bell) - optional",
"icon_overdue": "Icon overdue (mdi:bell-alert) - optional",
"forecast_dates": "Number of future due dates to forecast"
"forecast_dates": "Number of future due dates to forecast",
"show_overdue_today": "Show overdue chore today on calendar"
}
},
"detail": {
Expand Down

0 comments on commit 691aa94

Please sign in to comment.