Add album lifecycle events and fix Telegram notification service calls
- Add support for album renamed and deleted events with notification templates - Fix missing response_variable for all telegram service calls - Enhance debug notifications with formatted sections and Telegram diagnostics - Add reply_to_message_id debug logging for troubleshooting - Update version to 1.14.8 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
# - Optional: periodic summary notifications with album list and share URLs
|
# - Optional: periodic summary notifications with album list and share URLs
|
||||||
#
|
#
|
||||||
# Event Data from Immich:
|
# Event Data from Immich:
|
||||||
|
# Assets Added/Removed/Changed Events:
|
||||||
# - `hub_name`: Name of the Immich hub/instance that sent the event
|
# - `hub_name`: Name of the Immich hub/instance that sent the event
|
||||||
# - `album_id`: Album ID
|
# - `album_id`: Album ID
|
||||||
# - `album_name`: Album name
|
# - `album_name`: Album name
|
||||||
@@ -30,6 +31,18 @@
|
|||||||
# - `removed_assets`: List of removed asset IDs
|
# - `removed_assets`: List of removed asset IDs
|
||||||
# - `people`: List of all people detected in the album
|
# - `people`: List of all people detected in the album
|
||||||
#
|
#
|
||||||
|
# Album Renamed Event:
|
||||||
|
# - `hub_name`: Name of the Immich hub/instance that sent the event
|
||||||
|
# - `album_id`: Album ID
|
||||||
|
# - `old_name`: Previous album name
|
||||||
|
# - `new_name`: New album name
|
||||||
|
# - `album_url`: Public URL to view the album (only if album has shared link)
|
||||||
|
#
|
||||||
|
# Album Deleted Event:
|
||||||
|
# - `hub_name`: Name of the Immich hub/instance that sent the event
|
||||||
|
# - `album_id`: Album ID
|
||||||
|
# - `album_name`: Album name that was deleted
|
||||||
|
#
|
||||||
# Added Assets Fields (each item in `added_assets`):
|
# Added Assets Fields (each item in `added_assets`):
|
||||||
# - `id`: Unique asset ID
|
# - `id`: Unique asset ID
|
||||||
# - `asset_type`: Type of asset (IMAGE or VIDEO)
|
# - `asset_type`: Type of asset (IMAGE or VIDEO)
|
||||||
@@ -181,6 +194,20 @@ blueprint:
|
|||||||
selector:
|
selector:
|
||||||
boolean:
|
boolean:
|
||||||
|
|
||||||
|
track_album_renamed:
|
||||||
|
name: Track Album Renamed
|
||||||
|
description: "Send notifications when albums are renamed"
|
||||||
|
default: true
|
||||||
|
selector:
|
||||||
|
boolean:
|
||||||
|
|
||||||
|
track_album_deleted:
|
||||||
|
name: Track Album Deleted
|
||||||
|
description: "Send notifications when albums are deleted"
|
||||||
|
default: true
|
||||||
|
selector:
|
||||||
|
boolean:
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# Notification Configuration
|
# Notification Configuration
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
@@ -252,6 +279,26 @@ blueprint:
|
|||||||
text:
|
text:
|
||||||
multiline: true
|
multiline: true
|
||||||
|
|
||||||
|
message_album_renamed:
|
||||||
|
name: "Album Renamed Message"
|
||||||
|
description: >
|
||||||
|
Message sent when an album is renamed.
|
||||||
|
Variables: `{old_name}`, `{new_name}`, `{album_url}`
|
||||||
|
default: "✏️ Album \"{old_name}\" renamed to \"{new_name}\"."
|
||||||
|
selector:
|
||||||
|
text:
|
||||||
|
multiline: true
|
||||||
|
|
||||||
|
message_album_deleted:
|
||||||
|
name: "Album Deleted Message"
|
||||||
|
description: >
|
||||||
|
Message sent when an album is deleted.
|
||||||
|
Variables: `{album_name}`
|
||||||
|
default: "🗑️ Album \"{album_name}\" was deleted."
|
||||||
|
selector:
|
||||||
|
text:
|
||||||
|
multiline: true
|
||||||
|
|
||||||
message_people_format:
|
message_people_format:
|
||||||
name: "People Format"
|
name: "People Format"
|
||||||
description: >
|
description: >
|
||||||
@@ -522,6 +569,14 @@ trigger:
|
|||||||
event_type: immich_album_watcher_changed
|
event_type: immich_album_watcher_changed
|
||||||
id: "changed"
|
id: "changed"
|
||||||
|
|
||||||
|
- platform: event
|
||||||
|
event_type: immich_album_watcher_album_renamed
|
||||||
|
id: "album_renamed"
|
||||||
|
|
||||||
|
- platform: event
|
||||||
|
event_type: immich_album_watcher_album_deleted
|
||||||
|
id: "album_deleted"
|
||||||
|
|
||||||
# Periodic summary trigger (time pattern)
|
# Periodic summary trigger (time pattern)
|
||||||
# Note: Uses template to dynamically set interval, but HA requires static value
|
# Note: Uses template to dynamically set interval, but HA requires static value
|
||||||
# so we trigger every hour and check interval in conditions
|
# so we trigger every hour and check interval in conditions
|
||||||
@@ -558,6 +613,8 @@ variables:
|
|||||||
track_assets_removed: !input track_assets_removed
|
track_assets_removed: !input track_assets_removed
|
||||||
track_images: !input track_images
|
track_images: !input track_images
|
||||||
track_videos: !input track_videos
|
track_videos: !input track_videos
|
||||||
|
track_album_renamed: !input track_album_renamed
|
||||||
|
track_album_deleted: !input track_album_deleted
|
||||||
enable_debug_notifications: !input enable_debug_notifications
|
enable_debug_notifications: !input enable_debug_notifications
|
||||||
|
|
||||||
# Telegram Media Settings
|
# Telegram Media Settings
|
||||||
@@ -604,6 +661,8 @@ variables:
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
message_assets_added_template: !input message_assets_added
|
message_assets_added_template: !input message_assets_added
|
||||||
message_assets_removed_template: !input message_assets_removed
|
message_assets_removed_template: !input message_assets_removed
|
||||||
|
message_album_renamed_template: !input message_album_renamed
|
||||||
|
message_album_deleted_template: !input message_album_deleted
|
||||||
message_people_format_template: !input message_people_format
|
message_people_format_template: !input message_people_format
|
||||||
message_asset_image_template: !input message_asset_image
|
message_asset_image_template: !input message_asset_image
|
||||||
message_asset_video_template: !input message_asset_video
|
message_asset_video_template: !input message_asset_video
|
||||||
@@ -624,6 +683,10 @@ variables:
|
|||||||
event_people: "{{ trigger.event.data.people | default([]) }}"
|
event_people: "{{ trigger.event.data.people | default([]) }}"
|
||||||
event_added_assets: "{{ trigger.event.data.added_assets | default([]) }}"
|
event_added_assets: "{{ trigger.event.data.added_assets | default([]) }}"
|
||||||
|
|
||||||
|
# Album renamed event data
|
||||||
|
event_old_name: "{{ trigger.event.data.old_name | default('') }}"
|
||||||
|
event_new_name: "{{ trigger.event.data.new_name | default('') }}"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Computed Values
|
# Computed Values
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -725,6 +788,10 @@ variables:
|
|||||||
{% else %}
|
{% else %}
|
||||||
{{ false }}
|
{{ false }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif trigger.id == 'album_renamed' and track_album_renamed %}
|
||||||
|
{{ true }}
|
||||||
|
{% elif trigger.id == 'album_deleted' and track_album_deleted %}
|
||||||
|
{{ true }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ false }}
|
{{ false }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -818,6 +885,7 @@ action:
|
|||||||
for_each: "{{ telegram_chat_ids }}"
|
for_each: "{{ telegram_chat_ids }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: immich_album_watcher.send_telegram_notification
|
- service: immich_album_watcher.send_telegram_notification
|
||||||
|
response_variable: telegram_periodic_response
|
||||||
target:
|
target:
|
||||||
entity_id: "{{ album_id_entities[0] }}"
|
entity_id: "{{ album_id_entities[0] }}"
|
||||||
data:
|
data:
|
||||||
@@ -840,23 +908,36 @@ action:
|
|||||||
data:
|
data:
|
||||||
title: "Immich Album Watcher Debug"
|
title: "Immich Album Watcher Debug"
|
||||||
message: >
|
message: >
|
||||||
Trigger ID: {{ trigger.id }}
|
**Event Data:**
|
||||||
Hub: {{ event_hub_name }}
|
- Trigger ID: {{ trigger.id }}
|
||||||
Album: {{ event_album_name }}
|
- Hub: {{ event_hub_name }}
|
||||||
Album ID: {{ event_album_id }}
|
- Album: {{ event_album_name }}
|
||||||
Album URL: {{ event_album_url }}
|
- Album ID: {{ event_album_id }}
|
||||||
Change Type: {{ event_change_type }}
|
- Album URL: {{ event_album_url }}
|
||||||
Added Count (raw): {{ event_added_count }}
|
- Change Type: {{ event_change_type }}
|
||||||
Added Count (filtered): {{ filtered_added_count }}
|
|
||||||
Removed Count: {{ event_removed_count }}
|
**Asset Counts:**
|
||||||
Added Assets: {{ event_added_assets | length }}
|
- Added Count (raw): {{ event_added_count }}
|
||||||
People: {{ event_people | join(', ') }}
|
- Added Count (filtered): {{ filtered_added_count }}
|
||||||
Is Hub Tracked: {{ is_hub_tracked }}
|
- Removed Count: {{ event_removed_count }}
|
||||||
Is Album Tracked: {{ is_album_tracked }}
|
- Added Assets: {{ event_added_assets | length }}
|
||||||
Should Notify: {{ should_notify }}
|
|
||||||
Track Images: {{ track_images }}
|
**People:**
|
||||||
Track Videos: {{ track_videos }}
|
- {{ event_people | join(', ') if event_people | length > 0 else '(none)' }}
|
||||||
Include Asset Details: {{ include_asset_details }}
|
|
||||||
|
**Filtering:**
|
||||||
|
- Is Hub Tracked: {{ is_hub_tracked }}
|
||||||
|
- Is Album Tracked: {{ is_album_tracked }}
|
||||||
|
- Should Notify: {{ should_notify }}
|
||||||
|
- Track Images: {{ track_images }}
|
||||||
|
- Track Videos: {{ track_videos }}
|
||||||
|
- Include Asset Details: {{ include_asset_details }}
|
||||||
|
|
||||||
|
**Telegram:**
|
||||||
|
- Enabled: {{ send_telegram_media }}
|
||||||
|
- Chat IDs: {{ telegram_chat_ids | join(', ') if telegram_chat_ids | length > 0 else '(none)' }}
|
||||||
|
- Album Shared: {{ 'Yes' if event_album_url | length > 0 else 'No (media cannot be sent)' }}
|
||||||
|
- Assets with URLs: {{ assets_with_urls | length }}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Send Notification Based on Event Type
|
# Send Notification Based on Event Type
|
||||||
@@ -953,6 +1034,80 @@ action:
|
|||||||
data:
|
data:
|
||||||
message: "{{ message }}"
|
message: "{{ message }}"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# CASE 4: Album Renamed
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.id == 'album_renamed' and track_album_renamed }}"
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
message: >
|
||||||
|
{% set tpl = message_album_renamed_template %}
|
||||||
|
{{ tpl | replace('{old_name}', event_old_name)
|
||||||
|
| replace('{new_name}', event_new_name)
|
||||||
|
| replace('{album_url}', event_album_url) }}
|
||||||
|
|
||||||
|
- service: notify.send_message
|
||||||
|
target:
|
||||||
|
entity_id: "{{ notify_targets }}"
|
||||||
|
data:
|
||||||
|
message: "{{ message }}"
|
||||||
|
|
||||||
|
# Also send to Telegram if configured
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ send_telegram_media and telegram_chat_ids | length > 0 and album_id_entities | length > 0 }}"
|
||||||
|
sequence:
|
||||||
|
- repeat:
|
||||||
|
for_each: "{{ telegram_chat_ids }}"
|
||||||
|
sequence:
|
||||||
|
- service: immich_album_watcher.send_telegram_notification
|
||||||
|
response_variable: telegram_renamed_response
|
||||||
|
target:
|
||||||
|
entity_id: "{{ album_id_entities[0] }}"
|
||||||
|
data:
|
||||||
|
chat_id: "{{ repeat.item }}"
|
||||||
|
caption: "{{ message }}"
|
||||||
|
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# CASE 5: Album Deleted
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.id == 'album_deleted' and track_album_deleted }}"
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
message: >
|
||||||
|
{% set tpl = message_album_deleted_template %}
|
||||||
|
{{ tpl | replace('{album_name}', event_album_name) }}
|
||||||
|
|
||||||
|
- service: notify.send_message
|
||||||
|
target:
|
||||||
|
entity_id: "{{ notify_targets }}"
|
||||||
|
data:
|
||||||
|
message: "{{ message }}"
|
||||||
|
|
||||||
|
# Also send to Telegram if configured
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ send_telegram_media and telegram_chat_ids | length > 0 and album_id_entities | length > 0 }}"
|
||||||
|
sequence:
|
||||||
|
- repeat:
|
||||||
|
for_each: "{{ telegram_chat_ids }}"
|
||||||
|
sequence:
|
||||||
|
- service: immich_album_watcher.send_telegram_notification
|
||||||
|
response_variable: telegram_deleted_response
|
||||||
|
target:
|
||||||
|
entity_id: "{{ album_id_entities[0] }}"
|
||||||
|
data:
|
||||||
|
chat_id: "{{ repeat.item }}"
|
||||||
|
caption: "{{ message }}"
|
||||||
|
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Send Media to Telegram (if enabled)
|
# Send Media to Telegram (if enabled)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -1003,13 +1158,15 @@ action:
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% set used_url = download_url if download_url | length > 0 else view_url %}
|
{% set used_url = download_url if download_url | length > 0 else view_url %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
- {{ asset.asset_type }}: {{ asset.asset_filename | default('unknown') }}
|
|
||||||
Playback URL: {{ playback_url if playback_url | length > 0 else '(not available)' }}
|
**{{ loop.index }}. {{ asset.asset_type }}: {{ asset.asset_filename | default('unknown') }}**
|
||||||
Download URL: {{ download_url if download_url | length > 0 else '(not available)' }}
|
- Playback URL: {{ playback_url if playback_url | length > 0 else '(not available)' }}
|
||||||
View URL: {{ view_url if view_url | length > 0 else '(not available)' }}
|
- Download URL: {{ download_url if download_url | length > 0 else '(not available)' }}
|
||||||
**Using: {{ used_url if used_url | length > 0 else '(no URL!)' }}**
|
- View URL: {{ view_url if view_url | length > 0 else '(not available)' }}
|
||||||
|
- **Using: {{ used_url if used_url | length > 0 else '(no URL!)' }}**
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
---
|
||||||
**Note:** Media is sent via immich_album_watcher.send_telegram_notification service.
|
**Note:** Media is sent via immich_album_watcher.send_telegram_notification service.
|
||||||
Large lists are automatically split into multiple groups.
|
Large lists are automatically split into multiple groups.
|
||||||
|
|
||||||
@@ -1074,15 +1231,28 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ media_urls | length > 0 }}"
|
value_template: "{{ media_urls | length > 0 }}"
|
||||||
sequence:
|
sequence:
|
||||||
|
# Debug: Log reply_to_message_id value
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ enable_debug_notifications }}"
|
||||||
|
sequence:
|
||||||
|
- service: persistent_notification.create
|
||||||
|
data:
|
||||||
|
title: "Immich Album Watcher - Reply To Debug"
|
||||||
|
message: >
|
||||||
|
**Reply To Message ID Debug:**
|
||||||
|
- Value: {{ reply_to_message_id }}
|
||||||
|
|
||||||
- service: immich_album_watcher.send_telegram_notification
|
- service: immich_album_watcher.send_telegram_notification
|
||||||
|
response_variable: telegram_media_response
|
||||||
continue_on_error: true
|
continue_on_error: true
|
||||||
target:
|
target:
|
||||||
entity_id: "{{ album_id_entities[0] if album_id_entities | length > 0 else '' }}"
|
entity_id: "{{ album_id_entities[0] if album_id_entities | length > 0 else '' }}"
|
||||||
data:
|
data:
|
||||||
chat_id: "{{ current_chat_id }}"
|
chat_id: "{{ current_chat_id }}"
|
||||||
urls: "{{ media_urls }}"
|
urls: "{{ media_urls }}"
|
||||||
caption: "{{ event_album_name }}"
|
reply_to_message_id: "{{ reply_to_message_id }}"
|
||||||
reply_to_message_id: >
|
|
||||||
{{ reply_to_message_id if reply_to_message_id > 0 else omit }}
|
|
||||||
max_group_size: "{{ max_media_per_group }}"
|
max_group_size: "{{ max_media_per_group }}"
|
||||||
chunk_delay: "{{ telegram_media_delay }}"
|
chunk_delay: "{{ telegram_media_delay }}"
|
||||||
|
wait_for_response: false
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "1.13.0"
|
"version": "1.14.8"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user