Bump aioimmich to 0.8.0 (#145908)

This commit is contained in:
Michael 2025-06-01 21:14:19 +02:00 committed by GitHub
parent ed9fd2c643
commit 3cfcf382da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 206 additions and 105 deletions

View File

@ -8,5 +8,5 @@
"iot_class": "local_polling", "iot_class": "local_polling",
"loggers": ["aioimmich"], "loggers": ["aioimmich"],
"quality_scale": "silver", "quality_scale": "silver",
"requirements": ["aioimmich==0.7.0"] "requirements": ["aioimmich==0.8.0"]
} }

View File

@ -133,10 +133,10 @@ class ImmichMediaSource(MediaSource):
identifier=f"{identifier.unique_id}|albums|{album.album_id}", identifier=f"{identifier.unique_id}|albums|{album.album_id}",
media_class=MediaClass.DIRECTORY, media_class=MediaClass.DIRECTORY,
media_content_type=MediaClass.IMAGE, media_content_type=MediaClass.IMAGE,
title=album.name, title=album.album_name,
can_play=False, can_play=False,
can_expand=True, can_expand=True,
thumbnail=f"/immich/{identifier.unique_id}/{album.thumbnail_asset_id}/thumbnail/image/jpg", thumbnail=f"/immich/{identifier.unique_id}/{album.album_thumbnail_asset_id}/thumbnail/image/jpg",
) )
for album in albums for album in albums
] ]
@ -160,18 +160,19 @@ class ImmichMediaSource(MediaSource):
f"{identifier.unique_id}|albums|" f"{identifier.unique_id}|albums|"
f"{identifier.collection_id}|" f"{identifier.collection_id}|"
f"{asset.asset_id}|" f"{asset.asset_id}|"
f"{asset.file_name}|" f"{asset.original_file_name}|"
f"{asset.mime_type}" f"{mime_type}"
), ),
media_class=MediaClass.IMAGE, media_class=MediaClass.IMAGE,
media_content_type=asset.mime_type, media_content_type=mime_type,
title=asset.file_name, title=asset.original_file_name,
can_play=False, can_play=False,
can_expand=False, can_expand=False,
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{asset.mime_type}", thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{mime_type}",
) )
for asset in album_info.assets for asset in album_info.assets
if asset.mime_type.startswith("image/") if (mime_type := asset.original_mime_type)
and mime_type.startswith("image/")
] ]
ret.extend( ret.extend(
@ -181,18 +182,19 @@ class ImmichMediaSource(MediaSource):
f"{identifier.unique_id}|albums|" f"{identifier.unique_id}|albums|"
f"{identifier.collection_id}|" f"{identifier.collection_id}|"
f"{asset.asset_id}|" f"{asset.asset_id}|"
f"{asset.file_name}|" f"{asset.original_file_name}|"
f"{asset.mime_type}" f"{mime_type}"
), ),
media_class=MediaClass.VIDEO, media_class=MediaClass.VIDEO,
media_content_type=asset.mime_type, media_content_type=mime_type,
title=asset.file_name, title=asset.original_file_name,
can_play=True, can_play=True,
can_expand=False, can_expand=False,
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/image/jpeg", thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/image/jpeg",
) )
for asset in album_info.assets for asset in album_info.assets
if asset.mime_type.startswith("video/") if (mime_type := asset.original_mime_type)
and mime_type.startswith("video/")
) )
return ret return ret

2
requirements_all.txt generated
View File

@ -280,7 +280,7 @@ aiohue==4.7.4
aioimaplib==2.0.1 aioimaplib==2.0.1
# homeassistant.components.immich # homeassistant.components.immich
aioimmich==0.7.0 aioimmich==0.8.0
# homeassistant.components.apache_kafka # homeassistant.components.apache_kafka
aiokafka==0.10.0 aiokafka==0.10.0

View File

@ -265,7 +265,7 @@ aiohue==4.7.4
aioimaplib==2.0.1 aioimaplib==2.0.1
# homeassistant.components.immich # homeassistant.components.immich
aioimmich==0.7.0 aioimmich==0.8.0
# homeassistant.components.apache_kafka # homeassistant.components.apache_kafka
aiokafka==0.10.0 aiokafka==0.10.0

View File

@ -1,7 +1,6 @@
"""Common fixtures for the Immich tests.""" """Common fixtures for the Immich tests."""
from collections.abc import AsyncGenerator, Generator from collections.abc import AsyncGenerator, Generator
from datetime import datetime
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from aioimmich import ImmichAlbums, ImmichAssests, ImmichServer, ImmichUsers from aioimmich import ImmichAlbums, ImmichAssests, ImmichServer, ImmichUsers
@ -10,7 +9,7 @@ from aioimmich.server.models import (
ImmichServerStatistics, ImmichServerStatistics,
ImmichServerStorage, ImmichServerStorage,
) )
from aioimmich.users.models import AvatarColor, ImmichUser, UserStatus from aioimmich.users.models import ImmichUserObject
import pytest import pytest
from homeassistant.components.immich.const import DOMAIN from homeassistant.components.immich.const import DOMAIN
@ -78,36 +77,58 @@ def mock_immich_assets() -> AsyncMock:
def mock_immich_server() -> AsyncMock: def mock_immich_server() -> AsyncMock:
"""Mock the Immich server.""" """Mock the Immich server."""
mock = AsyncMock(spec=ImmichServer) mock = AsyncMock(spec=ImmichServer)
mock.async_get_about_info.return_value = ImmichServerAbout( mock.async_get_about_info.return_value = ImmichServerAbout.from_dict(
"v1.132.3", {
"some_url", "version": "v1.132.3",
False, "versionUrl": "https://github.com/immich-app/immich/releases/tag/v1.132.3",
None, "licensed": False,
None, "build": "14709928600",
None, "buildUrl": "https://github.com/immich-app/immich/actions/runs/14709928600",
None, "buildImage": "v1.132.3",
None, "buildImageUrl": "https://github.com/immich-app/immich/pkgs/container/immich-server",
None, "repository": "immich-app/immich",
None, "repositoryUrl": "https://github.com/immich-app/immich",
None, "sourceRef": "v1.132.3",
None, "sourceCommit": "02994883fe3f3972323bb6759d0170a4062f5236",
None, "sourceUrl": "https://github.com/immich-app/immich/commit/02994883fe3f3972323bb6759d0170a4062f5236",
None, "nodejs": "v22.14.0",
None, "exiftool": "13.00",
None, "ffmpeg": "7.0.2-7",
None, "libvips": "8.16.1",
"imagemagick": "7.1.1-47",
}
) )
mock.async_get_storage_info.return_value = ImmichServerStorage( mock.async_get_storage_info.return_value = ImmichServerStorage.from_dict(
"294.2 GiB", {
"142.9 GiB", "diskSize": "294.2 GiB",
"136.3 GiB", "diskUse": "142.9 GiB",
315926315008, "diskAvailable": "136.3 GiB",
153400434688, "diskSizeRaw": 315926315008,
146402975744, "diskUseRaw": 153400406016,
48.56, "diskAvailableRaw": 146403004416,
"diskUsagePercentage": 48.56,
}
) )
mock.async_get_server_statistics.return_value = ImmichServerStatistics( mock.async_get_server_statistics.return_value = ImmichServerStatistics.from_dict(
27038, 1836, 119525451912, 54291170551, 65234281361 {
"photos": 27038,
"videos": 1836,
"usage": 119525451912,
"usagePhotos": 54291170551,
"usageVideos": 65234281361,
"usageByUser": [
{
"userId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
"userName": "admin",
"photos": 27038,
"videos": 1836,
"usage": 119525451912,
"usagePhotos": 54291170551,
"usageVideos": 65234281361,
"quotaSizeInBytes": None,
}
],
}
) )
return mock return mock
@ -116,23 +137,26 @@ def mock_immich_server() -> AsyncMock:
def mock_immich_user() -> AsyncMock: def mock_immich_user() -> AsyncMock:
"""Mock the Immich server.""" """Mock the Immich server."""
mock = AsyncMock(spec=ImmichUsers) mock = AsyncMock(spec=ImmichUsers)
mock.async_get_my_user.return_value = ImmichUser( mock.async_get_my_user.return_value = ImmichUserObject.from_dict(
"e7ef5713-9dab-4bd4-b899-715b0ca4379e", {
"user@immich.local", "id": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
"user", "email": "user@immich.local",
"", "name": "user",
AvatarColor.PRIMARY, "profileImagePath": "",
datetime.fromisoformat("2025-05-11T10:07:46.866Z"), "avatarColor": "primary",
"user", "profileChangedAt": "2025-05-11T10:07:46.866Z",
False, "storageLabel": "user",
True, "shouldChangePassword": True,
datetime.fromisoformat("2025-05-11T10:07:46.866Z"), "isAdmin": True,
None, "createdAt": "2025-05-11T10:07:46.866Z",
None, "deletedAt": None,
"", "updatedAt": "2025-05-18T00:59:55.547Z",
None, "oauthId": "",
None, "quotaSizeInBytes": None,
UserStatus.ACTIVE, "quotaUsageInBytes": 119526467534,
"status": "active",
"license": None,
}
) )
return mock return mock

View File

@ -1,7 +1,6 @@
"""Constants for the Immich integration tests.""" """Constants for the Immich integration tests."""
from aioimmich.albums.models import ImmichAlbum from aioimmich.albums.models import ImmichAlbum
from aioimmich.assets.models import ImmichAsset
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
@ -26,27 +25,91 @@ MOCK_CONFIG_ENTRY_DATA = {
CONF_VERIFY_SSL: False, CONF_VERIFY_SSL: False,
} }
MOCK_ALBUM_WITHOUT_ASSETS = ImmichAlbum( ALBUM_DATA = {
"721e1a4b-aa12-441e-8d3b-5ac7ab283bb6", "id": "721e1a4b-aa12-441e-8d3b-5ac7ab283bb6",
"My Album", "albumName": "My Album",
"This is my first great album", "albumThumbnailAssetId": "0d03a7ad-ddc7-45a6-adee-68d322a6d2f5",
"0d03a7ad-ddc7-45a6-adee-68d322a6d2f5", "albumUsers": [],
1, "assetCount": 1,
[], "assets": [],
) "createdAt": "2025-05-11T10:13:22.799Z",
"hasSharedLink": False,
"isActivityEnabled": False,
"ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
"owner": {
"id": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
"email": "admin@immich.local",
"name": "admin",
"profileImagePath": "",
"avatarColor": "primary",
"profileChangedAt": "2025-05-11T10:07:46.866Z",
},
"shared": False,
"updatedAt": "2025-05-17T11:26:03.696Z",
}
MOCK_ALBUM_WITH_ASSETS = ImmichAlbum( MOCK_ALBUM_WITHOUT_ASSETS = ImmichAlbum.from_dict(ALBUM_DATA)
"721e1a4b-aa12-441e-8d3b-5ac7ab283bb6",
"My Album", MOCK_ALBUM_WITH_ASSETS = ImmichAlbum.from_dict(
"This is my first great album", {
"0d03a7ad-ddc7-45a6-adee-68d322a6d2f5", **ALBUM_DATA,
1, "assets": [
[ {
ImmichAsset( "id": "2e94c203-50aa-4ad2-8e29-56dd74e0eff4",
"2e94c203-50aa-4ad2-8e29-56dd74e0eff4", "filename.jpg", "image/jpeg" "deviceAssetId": "web-filename.jpg-1675185639000",
), "ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
ImmichAsset( "deviceId": "WEB",
"2e65a5f2-db83-44c4-81ab-f5ff20c9bd7b", "filename.mp4", "video/mp4" "libraryId": None,
), "type": "IMAGE",
], "originalPath": "upload/upload/e7ef5713-9dab-4bd4-b899-715b0ca4379e/b4/b8/b4b8ef00-8a6d-4056-91ff-7f86dc66e427.jpg",
"originalFileName": "filename.jpg",
"originalMimeType": "image/jpeg",
"thumbhash": "1igGFALX8mVGdHc5aChJf5nxNg==",
"fileCreatedAt": "2023-01-31T17:20:37.085+00:00",
"fileModifiedAt": "2023-01-31T17:20:39+00:00",
"localDateTime": "2023-01-31T18:20:37.085+00:00",
"updatedAt": "2025-05-11T10:13:49.590401+00:00",
"isFavorite": False,
"isArchived": False,
"isTrashed": False,
"duration": "0:00:00.00000",
"exifInfo": {},
"livePhotoVideoId": None,
"people": [],
"checksum": "HJm7TVOP80S+eiYZnAhWyRaB/Yc=",
"isOffline": False,
"hasMetadata": True,
"duplicateId": None,
"resized": True,
},
{
"id": "2e65a5f2-db83-44c4-81ab-f5ff20c9bd7b",
"deviceAssetId": "web-filename.mp4-1675185639000",
"ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
"deviceId": "WEB",
"libraryId": None,
"type": "IMAGE",
"originalPath": "upload/upload/e7ef5713-9dab-4bd4-b899-715b0ca4379e/b4/b8/b4b8ef00-8a6d-4056-eeff-7f86dc66e427.mp4",
"originalFileName": "filename.mp4",
"originalMimeType": "video/mp4",
"thumbhash": "1igGFALX8mVGdHc5aChJf5nxNg==",
"fileCreatedAt": "2023-01-31T17:20:37.085+00:00",
"fileModifiedAt": "2023-01-31T17:20:39+00:00",
"localDateTime": "2023-01-31T18:20:37.085+00:00",
"updatedAt": "2025-05-11T10:13:49.590401+00:00",
"isFavorite": False,
"isArchived": False,
"isTrashed": False,
"duration": "0:00:00.00000",
"exifInfo": {},
"livePhotoVideoId": None,
"people": [],
"checksum": "HJm7TVOP80S+eiYZnAhWyRaB/Yc=",
"isOffline": False,
"hasMetadata": True,
"duplicateId": None,
"resized": True,
},
],
}
) )

View File

@ -3,36 +3,48 @@
dict({ dict({
'data': dict({ 'data': dict({
'server_about': dict({ 'server_about': dict({
'build': None, 'build': '14709928600',
'build_image': None, 'build_image': 'v1.132.3',
'build_image_url': None, 'build_image_url': 'https://github.com/immich-app/immich/pkgs/container/immich-server',
'build_url': None, 'build_url': 'https://github.com/immich-app/immich/actions/runs/14709928600',
'exiftool': None, 'exiftool': '13.00',
'ffmpeg': None, 'ffmpeg': '7.0.2-7',
'imagemagick': None, 'imagemagick': '7.1.1-47',
'libvips': None, 'libvips': '8.16.1',
'licensed': False, 'licensed': False,
'nodejs': None, 'nodejs': 'v22.14.0',
'repository': None, 'repository': 'immich-app/immich',
'repository_url': None, 'repository_url': 'https://github.com/immich-app/immich',
'source_commit': None, 'source_commit': '02994883fe3f3972323bb6759d0170a4062f5236',
'source_ref': None, 'source_ref': 'v1.132.3',
'source_url': None, 'source_url': 'https://github.com/immich-app/immich/commit/02994883fe3f3972323bb6759d0170a4062f5236',
'version': 'v1.132.3', 'version': 'v1.132.3',
'version_url': 'some_url', 'version_url': 'https://github.com/immich-app/immich/releases/tag/v1.132.3',
}), }),
'server_storage': dict({ 'server_storage': dict({
'disk_available': '136.3 GiB', 'disk_available': '136.3 GiB',
'disk_available_raw': 146402975744, 'disk_available_raw': 146403004416,
'disk_size': '294.2 GiB', 'disk_size': '294.2 GiB',
'disk_size_raw': 315926315008, 'disk_size_raw': 315926315008,
'disk_usage_percentage': 48.56, 'disk_usage_percentage': 48.56,
'disk_use': '142.9 GiB', 'disk_use': '142.9 GiB',
'disk_use_raw': 153400434688, 'disk_use_raw': 153400406016,
}), }),
'server_usage': dict({ 'server_usage': dict({
'photos': 27038, 'photos': 27038,
'usage': 119525451912, 'usage': 119525451912,
'usage_by_user': list([
dict({
'photos': 27038,
'quota_size_in_bytes': None,
'usage': 119525451912,
'usage_photos': 54291170551,
'usage_videos': 65234281361,
'user_id': 'e7ef5713-9dab-4bd4-b899-715b0ca4379e',
'user_name': 'admin',
'videos': 1836,
}),
]),
'usage_photos': 54291170551, 'usage_photos': 54291170551,
'usage_videos': 65234281361, 'usage_videos': 65234281361,
'videos': 1836, 'videos': 1836,

View File

@ -55,7 +55,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '136.34839630127', 'state': '136.34842300415',
}) })
# --- # ---
# name: test_sensors[sensor.someone_disk_size-entry] # name: test_sensors[sensor.someone_disk_size-entry]
@ -225,7 +225,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '142.865287780762', 'state': '142.865261077881',
}) })
# --- # ---
# name: test_sensors[sensor.someone_disk_used_by_photos-entry] # name: test_sensors[sensor.someone_disk_used_by_photos-entry]