Add support for asset_description assert metadata

This commit is contained in:
2026-01-30 01:33:22 +03:00
parent 69b344142f
commit c49392af51
3 changed files with 14 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ A Home Assistant custom integration that monitors [Immich](https://immich.app/)
- Filename - Filename
- Creation date - Creation date
- Asset owner (who uploaded the asset) - Asset owner (who uploaded the asset)
- Asset description/caption
- Public URL (if album has a shared link) - Public URL (if album has a shared link)
- Detected people in the asset - Detected people in the asset
- **Services** - Custom service calls: - **Services** - Custom service calls:
@@ -132,6 +133,7 @@ Each item in the `added_assets` list contains the following fields:
| `asset_created` | Date/time when the asset was originally created | | `asset_created` | Date/time when the asset was originally created |
| `asset_owner` | Display name of the user who owns the asset | | `asset_owner` | Display name of the user who owns the asset |
| `asset_owner_id` | Unique ID of the user who owns the asset | | `asset_owner_id` | Unique ID of the user who owns the asset |
| `asset_description` | Description/caption of the asset (from EXIF data) |
| `asset_url` | Public URL to view the asset (only present if album has a shared link) | | `asset_url` | Public URL to view the asset (only present if album has a shared link) |
| `people` | List of people detected in this specific asset | | `people` | List of people detected in this specific asset |

View File

@@ -47,6 +47,7 @@ ATTR_ASSET_CREATED: Final = "asset_created"
ATTR_ASSET_OWNER: Final = "asset_owner" ATTR_ASSET_OWNER: Final = "asset_owner"
ATTR_ASSET_OWNER_ID: Final = "asset_owner_id" ATTR_ASSET_OWNER_ID: Final = "asset_owner_id"
ATTR_ASSET_URL: Final = "asset_url" ATTR_ASSET_URL: Final = "asset_url"
ATTR_ASSET_DESCRIPTION: Final = "asset_description"
# Asset types # Asset types
ASSET_TYPE_IMAGE: Final = "IMAGE" ASSET_TYPE_IMAGE: Final = "IMAGE"

View File

@@ -22,6 +22,7 @@ from .const import (
ATTR_ALBUM_NAME, ATTR_ALBUM_NAME,
ATTR_ALBUM_URL, ATTR_ALBUM_URL,
ATTR_ASSET_CREATED, ATTR_ASSET_CREATED,
ATTR_ASSET_DESCRIPTION,
ATTR_ASSET_FILENAME, ATTR_ASSET_FILENAME,
ATTR_ASSET_OWNER, ATTR_ASSET_OWNER,
ATTR_ASSET_OWNER_ID, ATTR_ASSET_OWNER_ID,
@@ -98,6 +99,7 @@ class AssetInfo:
created_at: str created_at: str
owner_id: str = "" owner_id: str = ""
owner_name: str = "" owner_name: str = ""
description: str = ""
people: list[str] = field(default_factory=list) people: list[str] = field(default_factory=list)
@classmethod @classmethod
@@ -114,6 +116,12 @@ class AssetInfo:
if users_cache and owner_id: if users_cache and owner_id:
owner_name = users_cache.get(owner_id, "") owner_name = users_cache.get(owner_id, "")
# Get description from exifInfo if available
description = ""
exif_info = data.get("exifInfo")
if exif_info:
description = exif_info.get("description", "") or ""
return cls( return cls(
id=data["id"], id=data["id"],
type=data.get("type", ASSET_TYPE_IMAGE), type=data.get("type", ASSET_TYPE_IMAGE),
@@ -121,6 +129,7 @@ class AssetInfo:
created_at=data.get("fileCreatedAt", ""), created_at=data.get("fileCreatedAt", ""),
owner_id=owner_id, owner_id=owner_id,
owner_name=owner_name, owner_name=owner_name,
description=description,
people=people, people=people,
) )
@@ -264,6 +273,7 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[dict[str, AlbumData]])
"type": asset.type, "type": asset.type,
"filename": asset.filename, "filename": asset.filename,
"created_at": asset.created_at, "created_at": asset.created_at,
"description": asset.description,
"people": asset.people, "people": asset.people,
"thumbnail_url": f"{self._url}/api/assets/{asset.id}/thumbnail", "thumbnail_url": f"{self._url}/api/assets/{asset.id}/thumbnail",
} }
@@ -554,6 +564,7 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[dict[str, AlbumData]])
ATTR_ASSET_CREATED: asset.created_at, ATTR_ASSET_CREATED: asset.created_at,
ATTR_ASSET_OWNER: asset.owner_name, ATTR_ASSET_OWNER: asset.owner_name,
ATTR_ASSET_OWNER_ID: asset.owner_id, ATTR_ASSET_OWNER_ID: asset.owner_id,
ATTR_ASSET_DESCRIPTION: asset.description,
ATTR_PEOPLE: asset.people, ATTR_PEOPLE: asset.people,
} }
# Add public URL if album has a shared link # Add public URL if album has a shared link