diff --git a/README.md b/README.md index 006f82f..d3f5798 100644 --- a/README.md +++ b/README.md @@ -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" ``` diff --git a/custom_components/immich_album_watcher/coordinator.py b/custom_components/immich_album_watcher/coordinator.py index ede7862..122e899 100644 --- a/custom_components/immich_album_watcher/coordinator.py +++ b/custom_components/immich_album_watcher/coordinator.py @@ -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: diff --git a/custom_components/immich_album_watcher/sensor.py b/custom_components/immich_album_watcher/sensor.py index 263c2c4..95ee066 100644 --- a/custom_components/immich_album_watcher/sensor.py +++ b/custom_components/immich_album_watcher/sensor.py @@ -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, diff --git a/custom_components/immich_album_watcher/services.yaml b/custom_components/immich_album_watcher/services.yaml index a0c68fe..b96c6e3 100644 --- a/custom_components/immich_album_watcher/services.yaml +++ b/custom_components/immich_album_watcher/services.yaml @@ -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: diff --git a/custom_components/immich_album_watcher/translations/en.json b/custom_components/immich_album_watcher/translations/en.json index 3f1ed06..8b19746 100644 --- a/custom_components/immich_album_watcher/translations/en.json +++ b/custom_components/immich_album_watcher/translations/en.json @@ -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", diff --git a/custom_components/immich_album_watcher/translations/ru.json b/custom_components/immich_album_watcher/translations/ru.json index dba56b7..bc943bb 100644 --- a/custom_components/immich_album_watcher/translations/ru.json +++ b/custom_components/immich_album_watcher/translations/ru.json @@ -175,9 +175,9 @@ "name": "Максимальная дата", "description": "Фильтровать файлы, созданные в эту дату или до (формат ISO 8601)." }, - "on_this_day": { - "name": "В этот день", - "description": "Фильтр по совпадению месяца и дня (воспоминания/годовщины)." + "memory_date": { + "name": "Дата воспоминания", + "description": "Фильтр по совпадению месяца и дня, исключая тот же год (воспоминания)." }, "city": { "name": "Город",