Expose favorite and asset rating to asset data
All checks were successful
Validate / Hassfest (push) Successful in 3s
All checks were successful
Validate / Hassfest (push) Successful in 3s
This commit is contained in:
@@ -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` | 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_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) |
|
| `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 |
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ ATTR_ASSET_URL: Final = "asset_url"
|
|||||||
ATTR_ASSET_DOWNLOAD_URL: Final = "asset_download_url"
|
ATTR_ASSET_DOWNLOAD_URL: Final = "asset_download_url"
|
||||||
ATTR_ASSET_PLAYBACK_URL: Final = "asset_playback_url"
|
ATTR_ASSET_PLAYBACK_URL: Final = "asset_playback_url"
|
||||||
ATTR_ASSET_DESCRIPTION: Final = "asset_description"
|
ATTR_ASSET_DESCRIPTION: Final = "asset_description"
|
||||||
|
ATTR_ASSET_IS_FAVORITE: Final = "asset_is_favorite"
|
||||||
|
ATTR_ASSET_RATING: Final = "asset_rating"
|
||||||
|
|
||||||
# Asset types
|
# Asset types
|
||||||
ASSET_TYPE_IMAGE: Final = "IMAGE"
|
ASSET_TYPE_IMAGE: Final = "IMAGE"
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ from .const import (
|
|||||||
ATTR_ASSET_DESCRIPTION,
|
ATTR_ASSET_DESCRIPTION,
|
||||||
ATTR_ASSET_DOWNLOAD_URL,
|
ATTR_ASSET_DOWNLOAD_URL,
|
||||||
ATTR_ASSET_FILENAME,
|
ATTR_ASSET_FILENAME,
|
||||||
|
ATTR_ASSET_IS_FAVORITE,
|
||||||
ATTR_ASSET_OWNER,
|
ATTR_ASSET_OWNER,
|
||||||
ATTR_ASSET_OWNER_ID,
|
ATTR_ASSET_OWNER_ID,
|
||||||
|
ATTR_ASSET_PLAYBACK_URL,
|
||||||
|
ATTR_ASSET_RATING,
|
||||||
ATTR_ASSET_TYPE,
|
ATTR_ASSET_TYPE,
|
||||||
ATTR_ASSET_URL,
|
ATTR_ASSET_URL,
|
||||||
ATTR_ASSET_PLAYBACK_URL,
|
|
||||||
ATTR_CHANGE_TYPE,
|
ATTR_CHANGE_TYPE,
|
||||||
ATTR_HUB_NAME,
|
ATTR_HUB_NAME,
|
||||||
ATTR_PEOPLE,
|
ATTR_PEOPLE,
|
||||||
@@ -115,6 +117,8 @@ class AssetInfo:
|
|||||||
owner_name: str = ""
|
owner_name: str = ""
|
||||||
description: str = ""
|
description: str = ""
|
||||||
people: list[str] = field(default_factory=list)
|
people: list[str] = field(default_factory=list)
|
||||||
|
is_favorite: bool = False
|
||||||
|
rating: int | None = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_api_response(
|
def from_api_response(
|
||||||
@@ -136,6 +140,10 @@ class AssetInfo:
|
|||||||
if exif_info:
|
if exif_info:
|
||||||
description = exif_info.get("description", "") or ""
|
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(
|
return cls(
|
||||||
id=data["id"],
|
id=data["id"],
|
||||||
type=data.get("type", ASSET_TYPE_IMAGE),
|
type=data.get("type", ASSET_TYPE_IMAGE),
|
||||||
@@ -145,6 +153,8 @@ class AssetInfo:
|
|||||||
owner_name=owner_name,
|
owner_name=owner_name,
|
||||||
description=description,
|
description=description,
|
||||||
people=people,
|
people=people,
|
||||||
|
is_favorite=is_favorite,
|
||||||
|
rating=rating,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -324,6 +334,8 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
|||||||
"created_at": asset.created_at,
|
"created_at": asset.created_at,
|
||||||
"description": asset.description,
|
"description": asset.description,
|
||||||
"people": asset.people,
|
"people": asset.people,
|
||||||
|
"is_favorite": asset.is_favorite,
|
||||||
|
"rating": asset.rating,
|
||||||
"thumbnail_url": f"{self._url}/api/assets/{asset.id}/thumbnail",
|
"thumbnail_url": f"{self._url}/api/assets/{asset.id}/thumbnail",
|
||||||
}
|
}
|
||||||
if asset.type == ASSET_TYPE_VIDEO:
|
if asset.type == ASSET_TYPE_VIDEO:
|
||||||
@@ -670,6 +682,8 @@ class ImmichAlbumWatcherCoordinator(DataUpdateCoordinator[AlbumData | None]):
|
|||||||
ATTR_ASSET_OWNER_ID: asset.owner_id,
|
ATTR_ASSET_OWNER_ID: asset.owner_id,
|
||||||
ATTR_ASSET_DESCRIPTION: asset.description,
|
ATTR_ASSET_DESCRIPTION: asset.description,
|
||||||
ATTR_PEOPLE: asset.people,
|
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)
|
asset_url = self._get_asset_public_url(asset.id)
|
||||||
if asset_url:
|
if asset_url:
|
||||||
|
|||||||
Reference in New Issue
Block a user