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:
@@ -151,7 +151,7 @@ data:
|
|||||||
asset_type: "all" # Options: "all", "photo", "video"
|
asset_type: "all" # Options: "all", "photo", "video"
|
||||||
min_date: "2024-01-01" # Optional: assets created on or after this date
|
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
|
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
|
city: "Paris" # Optional: filter by city name
|
||||||
state: "California" # Optional: filter by state/region
|
state: "California" # Optional: filter by state/region
|
||||||
country: "France" # Optional: filter by country
|
country: "France" # Optional: filter by country
|
||||||
@@ -177,7 +177,7 @@ data:
|
|||||||
- `"video"`: Return only videos
|
- `"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"`)
|
- `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"`)
|
- `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
|
- `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
|
- `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
|
- `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
|
entity_id: sensor.album_name_asset_limit
|
||||||
data:
|
data:
|
||||||
limit: 20
|
limit: 20
|
||||||
on_this_day: "{{ now().strftime('%Y-%m-%d') }}"
|
memory_date: "{{ now().strftime('%Y-%m-%d') }}"
|
||||||
order_by: "date"
|
order_by: "date"
|
||||||
order: "ascending"
|
order: "ascending"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
|||||||
asset_type: str = "all",
|
asset_type: str = "all",
|
||||||
min_date: str | None = None,
|
min_date: str | None = None,
|
||||||
max_date: str | None = None,
|
max_date: str | None = None,
|
||||||
on_this_day: str | None = None,
|
memory_date: str | None = None,
|
||||||
city: str | None = None,
|
city: str | None = None,
|
||||||
state: str | None = None,
|
state: str | None = None,
|
||||||
country: 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'
|
asset_type: Asset type filter - 'all', 'photo', or 'video'
|
||||||
min_date: Filter assets created on or after this date (ISO 8601 format)
|
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)
|
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)
|
city: Filter assets by city (case-insensitive substring match)
|
||||||
state: Filter assets by state/region (case-insensitive substring match)
|
state: Filter assets by state/region (case-insensitive substring match)
|
||||||
country: Filter assets by country (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:
|
if max_date:
|
||||||
assets = [a for a in assets if a.created_at <= max_date]
|
assets = [a for a in assets if a.created_at <= max_date]
|
||||||
|
|
||||||
# Apply "on this day" filtering (match month and day)
|
# Apply memory date filtering (match month and day, exclude same year)
|
||||||
if on_this_day:
|
if memory_date:
|
||||||
try:
|
try:
|
||||||
# Parse the reference date (supports ISO 8601 format)
|
# 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_month = ref_date.month
|
||||||
ref_day = ref_date.day
|
ref_day = ref_date.day
|
||||||
|
|
||||||
def matches_day(asset: AssetInfo) -> bool:
|
def matches_memory(asset: AssetInfo) -> bool:
|
||||||
"""Check if asset's date matches the reference month and day."""
|
"""Check if asset matches memory criteria (same month/day, different year)."""
|
||||||
try:
|
try:
|
||||||
asset_date = datetime.fromisoformat(
|
asset_date = datetime.fromisoformat(
|
||||||
asset.created_at.replace("Z", "+00:00")
|
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):
|
except (ValueError, AttributeError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
assets = [a for a in assets if matches_day(a)]
|
assets = [a for a in assets if matches_memory(a)]
|
||||||
except ValueError:
|
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)
|
# Apply geolocation filtering (case-insensitive substring match)
|
||||||
if city:
|
if city:
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ async def async_setup_entry(
|
|||||||
vol.Optional("asset_type", default="all"): vol.In(["all", "photo", "video"]),
|
vol.Optional("asset_type", default="all"): vol.In(["all", "photo", "video"]),
|
||||||
vol.Optional("min_date"): str,
|
vol.Optional("min_date"): str,
|
||||||
vol.Optional("max_date"): str,
|
vol.Optional("max_date"): str,
|
||||||
vol.Optional("on_this_day"): str,
|
vol.Optional("memory_date"): str,
|
||||||
vol.Optional("city"): str,
|
vol.Optional("city"): str,
|
||||||
vol.Optional("state"): str,
|
vol.Optional("state"): str,
|
||||||
vol.Optional("country"): str,
|
vol.Optional("country"): str,
|
||||||
@@ -211,7 +211,7 @@ class ImmichAlbumBaseSensor(CoordinatorEntity[ImmichAlbumWatcherCoordinator], Se
|
|||||||
asset_type: str = "all",
|
asset_type: str = "all",
|
||||||
min_date: str | None = None,
|
min_date: str | None = None,
|
||||||
max_date: str | None = None,
|
max_date: str | None = None,
|
||||||
on_this_day: str | None = None,
|
memory_date: str | None = None,
|
||||||
city: str | None = None,
|
city: str | None = None,
|
||||||
state: str | None = None,
|
state: str | None = None,
|
||||||
country: str | None = None,
|
country: str | None = None,
|
||||||
@@ -227,7 +227,7 @@ class ImmichAlbumBaseSensor(CoordinatorEntity[ImmichAlbumWatcherCoordinator], Se
|
|||||||
asset_type=asset_type,
|
asset_type=asset_type,
|
||||||
min_date=min_date,
|
min_date=min_date,
|
||||||
max_date=max_date,
|
max_date=max_date,
|
||||||
on_this_day=on_this_day,
|
memory_date=memory_date,
|
||||||
city=city,
|
city=city,
|
||||||
state=state,
|
state=state,
|
||||||
country=country,
|
country=country,
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ get_assets:
|
|||||||
required: false
|
required: false
|
||||||
selector:
|
selector:
|
||||||
text:
|
text:
|
||||||
on_this_day:
|
memory_date:
|
||||||
name: On This Day
|
name: Memory Date
|
||||||
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.
|
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
|
required: false
|
||||||
selector:
|
selector:
|
||||||
text:
|
text:
|
||||||
|
|||||||
@@ -175,9 +175,9 @@
|
|||||||
"name": "Maximum Date",
|
"name": "Maximum Date",
|
||||||
"description": "Filter assets created on or before this date (ISO 8601 format)."
|
"description": "Filter assets created on or before this date (ISO 8601 format)."
|
||||||
},
|
},
|
||||||
"on_this_day": {
|
"memory_date": {
|
||||||
"name": "On This Day",
|
"name": "Memory Date",
|
||||||
"description": "Filter assets by matching month and day (memories/anniversary filter)."
|
"description": "Filter assets by matching month and day, excluding the same year (memories filter)."
|
||||||
},
|
},
|
||||||
"city": {
|
"city": {
|
||||||
"name": "City",
|
"name": "City",
|
||||||
|
|||||||
@@ -175,9 +175,9 @@
|
|||||||
"name": "Максимальная дата",
|
"name": "Максимальная дата",
|
||||||
"description": "Фильтровать файлы, созданные в эту дату или до (формат ISO 8601)."
|
"description": "Фильтровать файлы, созданные в эту дату или до (формат ISO 8601)."
|
||||||
},
|
},
|
||||||
"on_this_day": {
|
"memory_date": {
|
||||||
"name": "В этот день",
|
"name": "Дата воспоминания",
|
||||||
"description": "Фильтр по совпадению месяца и дня (воспоминания/годовщины)."
|
"description": "Фильтр по совпадению месяца и дня, исключая тот же год (воспоминания)."
|
||||||
},
|
},
|
||||||
"city": {
|
"city": {
|
||||||
"name": "Город",
|
"name": "Город",
|
||||||
|
|||||||
Reference in New Issue
Block a user