Rename on_this_day to memory_date with exclude-same-year behavior
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:
2026-02-02 14:24:08 +03:00
parent e88fd0fa3a
commit a8ea9ab46a
6 changed files with 31 additions and 25 deletions

View File

@@ -151,7 +151,7 @@ data:
asset_type: "all" # Options: "all", "photo", "video"
min_date: "2024-01-01" # Optional: assets created on or after this date
max_date: "2024-12-31" # Optional: assets created on or before this date
on_this_day: "2024-02-14" # Optional: filter by month and day (memories)
memory_date: "2024-02-14" # Optional: memories filter (excludes same year)
city: "Paris" # Optional: filter by city name
state: "California" # Optional: filter by state/region
country: "France" # Optional: filter by country
@@ -177,7 +177,7 @@ data:
- `"video"`: Return only videos
- `min_date` (optional): Filter assets created on or after this date. Use ISO 8601 format (e.g., `"2024-01-01"` or `"2024-01-01T10:30:00"`)
- `max_date` (optional): Filter assets created on or before this date. Use ISO 8601 format (e.g., `"2024-12-31"` or `"2024-12-31T23:59:59"`)
- `on_this_day` (optional): 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` (optional): 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 all assets taken on February 14th from previous years
- `city` (optional): Filter assets by city name (case-insensitive substring match). Based on reverse geocoded location from asset GPS data
- `state` (optional): Filter assets by state/region name (case-insensitive substring match). Based on reverse geocoded location from asset GPS data
- `country` (optional): Filter assets by country name (case-insensitive substring match). Based on reverse geocoded location from asset GPS data
@@ -272,7 +272,7 @@ target:
entity_id: sensor.album_name_asset_limit
data:
limit: 20
on_this_day: "{{ now().strftime('%Y-%m-%d') }}"
memory_date: "{{ now().strftime('%Y-%m-%d') }}"
order_by: "date"
order: "ascending"
```

View File

@@ -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:

View File

@@ -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,

View File

@@ -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:

View File

@@ -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",

View File

@@ -175,9 +175,9 @@
"name": "Максимальная дата",
"description": "Фильтровать файлы, созданные в эту дату или до (формат ISO 8601)."
},
"on_this_day": {
"name": "В этот день",
"description": "Фильтр по совпадению месяца и дня (воспоминания/годовщины)."
"memory_date": {
"name": "Дата воспоминания",
"description": "Фильтр по совпадению месяца и дня, исключая тот же год (воспоминания)."
},
"city": {
"name": "Город",