1 Commits

Author SHA1 Message Date
13132323ea Add debug logging and quiet hours support to Immich Album Watcher Telegram notifications
- Add debug persistent notifications after all 13 send_telegram_notification calls
  (periodic summary, scheduled per-album/combined, memory per-album/combined,
  album renamed/deleted, assets added text/media) logging chat ID, caption,
  assets count, reply-to ID, and service response when debug mode is enabled
- Replace removed ignore_quiet_hours parameter with new quiet_hours_start and
  quiet_hours_end time inputs (defaults: 23:00-07:00) on all Telegram service calls
- Update README with quiet hours documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 00:42:26 +03:00
2 changed files with 261 additions and 0 deletions

View File

@@ -146,6 +146,7 @@ Select input_text entities containing Telegram chat IDs. Can be user IDs (positi
- Large media lists are automatically split into multiple groups (2-10 items per group)
- Optional chat action indicator (typing, uploading photo/video) while processing
- Optional maximum asset size filter to skip large files
- Respects integration quiet hours — notifications are queued and sent when quiet hours end (configurable bypass per blueprint instance)
### Limitations

View File

@@ -461,6 +461,23 @@ blueprint:
- label: "Uploading Document..."
value: "upload_document"
telegram_quiet_hours_start:
name: Quiet Hours Start
description: >
Start time for quiet hours. During quiet hours, Telegram notifications
are queued and sent when quiet hours end.
default: "23:00"
selector:
time:
telegram_quiet_hours_end:
name: Quiet Hours End
description: >
End time for quiet hours. Queued notifications are sent after this time.
default: "07:00"
selector:
time:
# -------------------------------------------------------------------------
# Periodic Summary
# -------------------------------------------------------------------------
@@ -937,6 +954,8 @@ variables:
telegram_disable_url_preview: !input telegram_disable_url_preview
telegram_chat_action: !input telegram_chat_action
telegram_max_asset_size: !input telegram_max_asset_size
telegram_quiet_hours_start: !input telegram_quiet_hours_start
telegram_quiet_hours_end: !input telegram_quiet_hours_end
# Periodic Summary Settings
enable_periodic_summary: !input enable_periodic_summary
@@ -1437,6 +1456,25 @@ action:
assets: "{{ [{'url': periodic_summary_image_url, 'type': 'photo'}] if periodic_summary_image_url | length > 0 else [] }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Periodic Summary - Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ periodic_summary_formatted[:200] }}...
- Has Image: {{ 'Yes' if periodic_summary_image_url | length > 0 else 'No' }}
- Response: {{ telegram_periodic_response }}
# Delay between periodic summary and scheduled assets if both trigger at the same hour
- if:
@@ -1681,6 +1719,24 @@ action:
caption: "{{ scheduled_message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Scheduled Per-Album - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ scheduled_message[:200] }}...
- Response: {{ telegram_scheduled_text_response }}
# Extract message ID for reply
- variables:
@@ -1710,6 +1766,25 @@ action:
max_asset_data_size: "{{ telegram_max_asset_size | int * 1048576 }}"
wait_for_response: false
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log media send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Scheduled Per-Album - Media Send:**
- Chat ID: {{ repeat.item }}
- Assets: {{ scheduled_media_urls | length }}
- Reply To: {{ scheduled_reply_to_id }}
- Response: {{ telegram_scheduled_media_response }}
# Combined Mode: Fetch from all albums and combine into one notification
# Distributes the limit evenly across albums (e.g., limit=10 with 2 albums = 5 each)
@@ -1941,6 +2016,24 @@ action:
caption: "{{ combined_message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Scheduled Combined - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ combined_message[:200] }}...
- Response: {{ telegram_combined_text_response }}
- variables:
combined_reply_to_id: "{{ telegram_combined_text_response[album_id_entities[0]].message_id | default(0) | int }}"
@@ -1968,6 +2061,25 @@ action:
max_asset_data_size: "{{ telegram_max_asset_size | int * 1048576 }}"
wait_for_response: false
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log media send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Scheduled Combined - Media Send:**
- Chat ID: {{ repeat.item }}
- Assets: {{ combined_media_urls | length }}
- Reply To: {{ combined_reply_to_id }}
- Response: {{ telegram_combined_media_response }}
# Delay before memory mode if another scheduled notification was sent at the same hour
- if:
@@ -2207,6 +2319,24 @@ action:
caption: "{{ memory_message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Memory Per-Album - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ memory_message[:200] }}...
- Response: {{ telegram_memory_text_response }}
# Extract message ID for reply
- variables:
@@ -2236,6 +2366,25 @@ action:
max_asset_data_size: "{{ telegram_max_asset_size | int * 1048576 }}"
wait_for_response: false
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log media send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Memory Per-Album - Media Send:**
- Chat ID: {{ repeat.item }}
- Assets: {{ memory_media_urls | length }}
- Reply To: {{ memory_reply_to_id }}
- Response: {{ telegram_memory_media_response }}
# Combined Mode: Fetch from all albums and combine into one notification
- conditions:
@@ -2457,6 +2606,24 @@ action:
caption: "{{ memory_comb_message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Memory Combined - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ memory_comb_message[:200] }}...
- Response: {{ telegram_memory_comb_text_response }}
- variables:
memory_comb_reply_to_id: "{{ telegram_memory_comb_text_response[album_id_entities[0]].message_id | default(0) | int }}"
@@ -2484,6 +2651,25 @@ action:
max_asset_data_size: "{{ telegram_max_asset_size | int * 1048576 }}"
wait_for_response: false
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log media send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Memory Combined - Media Send:**
- Chat ID: {{ repeat.item }}
- Assets: {{ memory_comb_media_urls | length }}
- Reply To: {{ memory_comb_reply_to_id }}
- Response: {{ telegram_memory_comb_media_response }}
# Stop here if this was a scheduled trigger - don't continue to event-based actions
- choose:
@@ -2686,6 +2872,24 @@ action:
caption: "{{ message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Album Renamed - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ message[:200] }}...
- Response: {{ telegram_renamed_response }}
# ---------------------------------------------------------------------
# CASE 5: Album Deleted
@@ -2723,6 +2927,24 @@ action:
caption: "{{ message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Album Deleted - Text Send:**
- Chat ID: {{ repeat.item }}
- Caption: {{ message[:200] }}...
- Response: {{ telegram_deleted_response }}
# ---------------------------------------------------------------------------
# Send Media to Telegram (if enabled)
@@ -2849,6 +3071,24 @@ action:
caption: "{{ telegram_message }}"
disable_web_page_preview: "{{ telegram_disable_url_preview }}"
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log text send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Assets Added - Text Send:**
- Chat ID: {{ current_chat_id }}
- Caption: {{ telegram_message[:200] }}...
- Response: {{ telegram_text_response }}
# Extract message ID for replies
- variables:
@@ -2891,3 +3131,23 @@ action:
max_asset_data_size: "{{ telegram_max_asset_size | int * 1048576 }}"
wait_for_response: false
chat_action: "{{ telegram_chat_action }}"
quiet_hours_start: "{{ telegram_quiet_hours_start }}"
quiet_hours_end: "{{ telegram_quiet_hours_end }}"
# Debug: Log media send result
- choose:
- conditions:
- condition: template
value_template: "{{ enable_debug_notifications }}"
sequence:
- service: persistent_notification.create
data:
title: "Immich Album Watcher - Telegram Send Debug"
message: >
**Assets Added - Media Send:**
- Chat ID: {{ current_chat_id }}
- Assets: {{ media_urls | length }}
- Reply To: {{ reply_to_message_id }}
- Max Group Size: {{ max_media_per_group }}
- Response: {{ telegram_media_response }}