Rename on_this_day to memory_date with exclude-same-year behavior
All checks were successful
Validate / Hassfest (push) Successful in 2s
All checks were successful
Validate / Hassfest (push) Successful in 2s
Renamed the date filter parameter and changed default behavior to match Google Photos memories - now excludes assets from the same year as the reference date, returning only photos from previous years on that day. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -443,7 +443,7 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
||||
asset_type: str = "all",
|
||||
min_date: str | None = None,
|
||||
max_date: str | None = None,
|
||||
on_this_day: str | None = None,
|
||||
memory_date: str | None = None,
|
||||
city: str | None = None,
|
||||
state: str | None = None,
|
||||
country: str | None = None,
|
||||
@@ -460,7 +460,7 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
||||
asset_type: Asset type filter - 'all', 'photo', or 'video'
|
||||
min_date: Filter assets created on or after this date (ISO 8601 format)
|
||||
max_date: Filter assets created on or before this date (ISO 8601 format)
|
||||
on_this_day: Filter assets by matching month and day (ISO 8601 format)
|
||||
memory_date: Filter assets by matching month and day, excluding the same year (memories filter)
|
||||
city: Filter assets by city (case-insensitive substring match)
|
||||
state: Filter assets by state/region (case-insensitive substring match)
|
||||
country: Filter assets by country (case-insensitive substring match)
|
||||
@@ -494,27 +494,33 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
||||
if max_date:
|
||||
assets = [a for a in assets if a.created_at <= max_date]
|
||||
|
||||
# Apply "on this day" filtering (match month and day)
|
||||
if on_this_day:
|
||||
# Apply memory date filtering (match month and day, exclude same year)
|
||||
if memory_date:
|
||||
try:
|
||||
# Parse the reference date (supports ISO 8601 format)
|
||||
ref_date = datetime.fromisoformat(on_this_day.replace("Z", "+00:00"))
|
||||
ref_date = datetime.fromisoformat(memory_date.replace("Z", "+00:00"))
|
||||
ref_year = ref_date.year
|
||||
ref_month = ref_date.month
|
||||
ref_day = ref_date.day
|
||||
|
||||
def matches_day(asset: AssetInfo) -> bool:
|
||||
"""Check if asset's date matches the reference month and day."""
|
||||
def matches_memory(asset: AssetInfo) -> bool:
|
||||
"""Check if asset matches memory criteria (same month/day, different year)."""
|
||||
try:
|
||||
asset_date = datetime.fromisoformat(
|
||||
asset.created_at.replace("Z", "+00:00")
|
||||
)
|
||||
return asset_date.month == ref_month and asset_date.day == ref_day
|
||||
# Match month and day, but exclude same year (true memories behavior)
|
||||
return (
|
||||
asset_date.month == ref_month
|
||||
and asset_date.day == ref_day
|
||||
and asset_date.year != ref_year
|
||||
)
|
||||
except (ValueError, AttributeError):
|
||||
return False
|
||||
|
||||
assets = [a for a in assets if matches_day(a)]
|
||||
assets = [a for a in assets if matches_memory(a)]
|
||||
except ValueError:
|
||||
_LOGGER.warning("Invalid on_this_day date format: %s", on_this_day)
|
||||
_LOGGER.warning("Invalid memory_date format: %s", memory_date)
|
||||
|
||||
# Apply geolocation filtering (case-insensitive substring match)
|
||||
if city:
|
||||
|
||||
@@ -114,7 +114,7 @@ async def async_setup_entry(
|
||||
vol.Optional("asset_type", default="all"): vol.In(["all", "photo", "video"]),
|
||||
vol.Optional("min_date"): str,
|
||||
vol.Optional("max_date"): str,
|
||||
vol.Optional("on_this_day"): str,
|
||||
vol.Optional("memory_date"): str,
|
||||
vol.Optional("city"): str,
|
||||
vol.Optional("state"): str,
|
||||
vol.Optional("country"): str,
|
||||
@@ -211,7 +211,7 @@ class ImmichAlbumBaseSensor(CoordinatorEntity[ImmichAlbumWatcherCoordinator], Se
|
||||
asset_type: str = "all",
|
||||
min_date: str | None = None,
|
||||
max_date: str | None = None,
|
||||
on_this_day: str | None = None,
|
||||
memory_date: str | None = None,
|
||||
city: str | None = None,
|
||||
state: str | None = None,
|
||||
country: str | None = None,
|
||||
@@ -227,7 +227,7 @@ class ImmichAlbumBaseSensor(CoordinatorEntity[ImmichAlbumWatcherCoordinator], Se
|
||||
asset_type=asset_type,
|
||||
min_date=min_date,
|
||||
max_date=max_date,
|
||||
on_this_day=on_this_day,
|
||||
memory_date=memory_date,
|
||||
city=city,
|
||||
state=state,
|
||||
country=country,
|
||||
|
||||
@@ -104,9 +104,9 @@ get_assets:
|
||||
required: false
|
||||
selector:
|
||||
text:
|
||||
on_this_day:
|
||||
name: On This Day
|
||||
description: Filter assets by matching month and day (memories/anniversary filter). Provide a date in ISO 8601 format (e.g., 2024-02-14) to get all assets taken on February 14th of any year.
|
||||
memory_date:
|
||||
name: Memory Date
|
||||
description: Filter assets by matching month and day, excluding the same year (memories filter like Google Photos). Provide a date in ISO 8601 format (e.g., 2024-02-14) to get assets from February 14th of previous years.
|
||||
required: false
|
||||
selector:
|
||||
text:
|
||||
|
||||
@@ -175,9 +175,9 @@
|
||||
"name": "Maximum Date",
|
||||
"description": "Filter assets created on or before this date (ISO 8601 format)."
|
||||
},
|
||||
"on_this_day": {
|
||||
"name": "On This Day",
|
||||
"description": "Filter assets by matching month and day (memories/anniversary filter)."
|
||||
"memory_date": {
|
||||
"name": "Memory Date",
|
||||
"description": "Filter assets by matching month and day, excluding the same year (memories filter)."
|
||||
},
|
||||
"city": {
|
||||
"name": "City",
|
||||
|
||||
@@ -175,9 +175,9 @@
|
||||
"name": "Максимальная дата",
|
||||
"description": "Фильтровать файлы, созданные в эту дату или до (формат ISO 8601)."
|
||||
},
|
||||
"on_this_day": {
|
||||
"name": "В этот день",
|
||||
"description": "Фильтр по совпадению месяца и дня (воспоминания/годовщины)."
|
||||
"memory_date": {
|
||||
"name": "Дата воспоминания",
|
||||
"description": "Фильтр по совпадению месяца и дня, исключая тот же год (воспоминания)."
|
||||
},
|
||||
"city": {
|
||||
"name": "Город",
|
||||
|
||||
Reference in New Issue
Block a user