From bbcd97e1acbd948bd5f3328f0549ec7ba545f1e0 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sat, 31 Jan 2026 18:14:33 +0300 Subject: [PATCH] Expose favorite and asset rating to asset data --- README.md | 2 ++ custom_components/immich_album_watcher/const.py | 2 ++ .../immich_album_watcher/coordinator.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7341ecd..c3de98a 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,8 @@ Each item in the `added_assets` list contains the following fields: | `asset_owner` | Display name 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_is_favorite` | Whether the asset is marked as favorite (`true` or `false`) | +| `asset_rating` | User rating of the asset (1-5 stars, or `null` if not rated) | | `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 | diff --git a/custom_components/immich_album_watcher/const.py b/custom_components/immich_album_watcher/const.py index be19f06..745c739 100644 --- a/custom_components/immich_album_watcher/const.py +++ b/custom_components/immich_album_watcher/const.py @@ -66,6 +66,8 @@ ATTR_ASSET_URL: Final = "asset_url" ATTR_ASSET_DOWNLOAD_URL: Final = "asset_download_url" ATTR_ASSET_PLAYBACK_URL: Final = "asset_playback_url" ATTR_ASSET_DESCRIPTION: Final = "asset_description" +ATTR_ASSET_IS_FAVORITE: Final = "asset_is_favorite" +ATTR_ASSET_RATING: Final = "asset_rating" # Asset types ASSET_TYPE_IMAGE: Final = "IMAGE" diff --git a/custom_components/immich_album_watcher/coordinator.py b/custom_components/immich_album_watcher/coordinator.py index 8321627..e7440ad 100644 --- a/custom_components/immich_album_watcher/coordinator.py +++ b/custom_components/immich_album_watcher/coordinator.py @@ -28,11 +28,13 @@ from .const import ( ATTR_ASSET_DESCRIPTION, ATTR_ASSET_DOWNLOAD_URL, ATTR_ASSET_FILENAME, + ATTR_ASSET_IS_FAVORITE, ATTR_ASSET_OWNER, ATTR_ASSET_OWNER_ID, + ATTR_ASSET_PLAYBACK_URL, + ATTR_ASSET_RATING, ATTR_ASSET_TYPE, ATTR_ASSET_URL, - ATTR_ASSET_PLAYBACK_URL, ATTR_CHANGE_TYPE, ATTR_HUB_NAME, ATTR_PEOPLE, @@ -115,6 +117,8 @@ class AssetInfo: owner_name: str = "" description: str = "" people: list[str] = field(default_factory=list) + is_favorite: bool = False + rating: int | None = None @classmethod def from_api_response( @@ -136,6 +140,10 @@ class AssetInfo: if exif_info: description = exif_info.get("description", "") or "" + # Get favorites and rating + is_favorite = data.get("isFavorite", False) + rating = data.get("exifInfo", {}).get("rating") if exif_info else None + return cls( id=data["id"], type=data.get("type", ASSET_TYPE_IMAGE), @@ -145,6 +153,8 @@ class AssetInfo: owner_name=owner_name, description=description, people=people, + is_favorite=is_favorite, + rating=rating, ) @@ -324,6 +334,8 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]): "created_at": asset.created_at, "description": asset.description, "people": asset.people, + "is_favorite": asset.is_favorite, + "rating": asset.rating, "thumbnail_url": f"{self._url}/api/assets/{asset.id}/thumbnail", } if asset.type == ASSET_TYPE_VIDEO: @@ -670,6 +682,8 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]): ATTR_ASSET_OWNER_ID: asset.owner_id, ATTR_ASSET_DESCRIPTION: asset.description, ATTR_PEOPLE: asset.people, + ATTR_ASSET_IS_FAVORITE: asset.is_favorite, + ATTR_ASSET_RATING: asset.rating, } asset_url = self._get_asset_public_url(asset.id) if asset_url: