Some checks failed
Validate / Hassfest (push) Has been cancelled
Wire the integration to delegate all HA-independent logic to immich-watcher-core, eliminating ~2300 lines of duplicated code. Changes: - const.py: Import shared constants from core, keep HA-specific ones - storage.py: Create HAStorageBackend adapter wrapping HA's Store, use core TelegramFileCache and NotificationQueue via adapter - coordinator.py: Delegate to core ImmichClient for API calls, detect_album_changes() for change detection, and asset_utils for filtering/sorting/URL building. Keep HA-specific event firing. - sensor.py: Replace ~1300 lines of Telegram code with 15-line delegation to core TelegramClient. Keep entity classes unchanged. - __init__.py: Use factory functions for creating core instances with HA storage backends - manifest.json: Add immich-watcher-core dependency Integration line count: 3600 -> 1295 lines (-64%) Zero behavior changes for end users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
"""Constants for the Immich Album Watcher integration."""
|
|
|
|
from typing import Final
|
|
|
|
# Re-export shared constants from core library
|
|
from immich_watcher_core.constants import ( # noqa: F401
|
|
ASSET_TYPE_IMAGE,
|
|
ASSET_TYPE_VIDEO,
|
|
ATTR_ADDED_ASSETS,
|
|
ATTR_ADDED_COUNT,
|
|
ATTR_ALBUM_ID,
|
|
ATTR_ALBUM_NAME,
|
|
ATTR_ALBUM_PROTECTED_PASSWORD,
|
|
ATTR_ALBUM_PROTECTED_URL,
|
|
ATTR_ALBUM_URL,
|
|
ATTR_ALBUM_URLS,
|
|
ATTR_ASSET_CITY,
|
|
ATTR_ASSET_COUNT,
|
|
ATTR_ASSET_COUNTRY,
|
|
ATTR_ASSET_CREATED,
|
|
ATTR_ASSET_DESCRIPTION,
|
|
ATTR_ASSET_DOWNLOAD_URL,
|
|
ATTR_ASSET_FILENAME,
|
|
ATTR_ASSET_IS_FAVORITE,
|
|
ATTR_ASSET_LATITUDE,
|
|
ATTR_ASSET_LONGITUDE,
|
|
ATTR_ASSET_OWNER,
|
|
ATTR_ASSET_OWNER_ID,
|
|
ATTR_ASSET_PLAYBACK_URL,
|
|
ATTR_ASSET_RATING,
|
|
ATTR_ASSET_STATE,
|
|
ATTR_ASSET_TYPE,
|
|
ATTR_ASSET_URL,
|
|
ATTR_CHANGE_TYPE,
|
|
ATTR_CREATED_AT,
|
|
ATTR_HUB_NAME,
|
|
ATTR_LAST_UPDATED,
|
|
ATTR_NEW_NAME,
|
|
ATTR_NEW_SHARED,
|
|
ATTR_OLD_NAME,
|
|
ATTR_OLD_SHARED,
|
|
ATTR_OWNER,
|
|
ATTR_PEOPLE,
|
|
ATTR_PHOTO_COUNT,
|
|
ATTR_REMOVED_ASSETS,
|
|
ATTR_REMOVED_COUNT,
|
|
ATTR_SHARED,
|
|
ATTR_THUMBNAIL_URL,
|
|
ATTR_VIDEO_COUNT,
|
|
DEFAULT_SCAN_INTERVAL,
|
|
DEFAULT_SHARE_PASSWORD,
|
|
DEFAULT_TELEGRAM_CACHE_TTL,
|
|
NEW_ASSETS_RESET_DELAY,
|
|
)
|
|
|
|
# HA-specific constants
|
|
DOMAIN: Final = "immich_album_watcher"
|
|
|
|
# Configuration keys
|
|
CONF_HUB_NAME: Final = "hub_name"
|
|
CONF_IMMICH_URL: Final = "immich_url"
|
|
CONF_API_KEY: Final = "api_key"
|
|
CONF_ALBUMS: Final = "albums"
|
|
CONF_ALBUM_ID: Final = "album_id"
|
|
CONF_ALBUM_NAME: Final = "album_name"
|
|
CONF_SCAN_INTERVAL: Final = "scan_interval"
|
|
CONF_TELEGRAM_BOT_TOKEN: Final = "telegram_bot_token"
|
|
CONF_TELEGRAM_CACHE_TTL: Final = "telegram_cache_ttl"
|
|
|
|
# Subentry type
|
|
SUBENTRY_TYPE_ALBUM: Final = "album"
|
|
|
|
# HA event names (prefixed with domain)
|
|
EVENT_ALBUM_CHANGED: Final = f"{DOMAIN}_album_changed"
|
|
EVENT_ASSETS_ADDED: Final = f"{DOMAIN}_assets_added"
|
|
EVENT_ASSETS_REMOVED: Final = f"{DOMAIN}_assets_removed"
|
|
EVENT_ALBUM_RENAMED: Final = f"{DOMAIN}_album_renamed"
|
|
EVENT_ALBUM_DELETED: Final = f"{DOMAIN}_album_deleted"
|
|
EVENT_ALBUM_SHARING_CHANGED: Final = f"{DOMAIN}_album_sharing_changed"
|
|
|
|
# Platforms
|
|
PLATFORMS: Final = ["sensor", "binary_sensor", "camera", "text", "button"]
|
|
|
|
# Services
|
|
SERVICE_REFRESH: Final = "refresh"
|
|
SERVICE_GET_ASSETS: Final = "get_assets"
|
|
SERVICE_SEND_TELEGRAM_NOTIFICATION: Final = "send_telegram_notification"
|