Move quiet hours from hub config to per-call service params
All checks were successful
Validate / Hassfest (push) Successful in 1m19s

Quiet hours are now specified per send_telegram_notification call via
quiet_hours_start/quiet_hours_end params instead of being a hub-wide
integration option. This allows different automations to use different
quiet hours windows (or none at all).

- Remove quiet_hours_start/end from config options UI and const.py
- Add quiet_hours_start/end as optional HH:MM params on the service
- Remove ignore_quiet_hours param (omit quiet hours params to send immediately)
- Queue stores quiet_hours_end per item; each unique end time gets its
  own async_track_time_change timer for replay
- On startup, items whose quiet hours have passed are sent immediately
- Add async_remove_indices() to NotificationQueue for selective removal
- Timers are cleaned up when no more items need them

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 12:04:20 +03:00
parent 678e8a6e62
commit 71b79cd919
8 changed files with 193 additions and 155 deletions

View File

@@ -113,10 +113,6 @@
}
},
"options": {
"error": {
"invalid_time_format": "Invalid time format. Use HH:MM (e.g. 22:00)",
"quiet_hours_incomplete": "Both start and end times must be set for quiet hours"
},
"step": {
"init": {
"title": "Immich Album Watcher Options",
@@ -124,16 +120,12 @@
"data": {
"scan_interval": "Scan interval (seconds)",
"telegram_bot_token": "Telegram Bot Token",
"telegram_cache_ttl": "Telegram Cache TTL (hours)",
"quiet_hours_start": "Quiet Hours Start",
"quiet_hours_end": "Quiet Hours End"
"telegram_cache_ttl": "Telegram Cache TTL (hours)"
},
"data_description": {
"scan_interval": "How often to check for album changes (10-3600 seconds)",
"telegram_bot_token": "Bot token for sending notifications to Telegram",
"telegram_cache_ttl": "How long to cache uploaded file IDs to avoid re-uploading (1-168 hours, default: 48)",
"quiet_hours_start": "Start time for quiet hours (HH:MM format, e.g. 22:00). Notifications will be queued during this period. Leave empty to disable.",
"quiet_hours_end": "End time for quiet hours (HH:MM format, e.g. 08:00). Queued notifications will be sent at this time."
"telegram_cache_ttl": "How long to cache uploaded file IDs to avoid re-uploading (1-168 hours, default: 48)"
}
}
}
@@ -257,9 +249,13 @@
"name": "Chat Action",
"description": "Chat action to display while processing (typing, upload_photo, upload_video, upload_document). Set to empty to disable."
},
"ignore_quiet_hours": {
"name": "Ignore Quiet Hours",
"description": "Send notification immediately even during quiet hours. By default, notifications are queued during quiet hours and sent when they end."
"quiet_hours_start": {
"name": "Quiet Hours Start",
"description": "Start time for quiet hours (HH:MM format, e.g. 22:00). Notifications during this period are queued and sent when quiet hours end. Omit to send immediately."
},
"quiet_hours_end": {
"name": "Quiet Hours End",
"description": "End time for quiet hours (HH:MM format, e.g. 08:00). Queued notifications will be sent at this time."
}
}
}

View File

@@ -113,10 +113,6 @@
}
},
"options": {
"error": {
"invalid_time_format": "Неверный формат времени. Используйте ЧЧ:ММ (например 22:00)",
"quiet_hours_incomplete": "Необходимо указать и начало, и конец тихих часов"
},
"step": {
"init": {
"title": "Настройки Immich Album Watcher",
@@ -124,16 +120,12 @@
"data": {
"scan_interval": "Интервал сканирования (секунды)",
"telegram_bot_token": "Токен Telegram бота",
"telegram_cache_ttl": "Время жизни кэша Telegram (часы)",
"quiet_hours_start": "Начало тихих часов",
"quiet_hours_end": "Конец тихих часов"
"telegram_cache_ttl": "Время жизни кэша Telegram (часы)"
},
"data_description": {
"scan_interval": "Как часто проверять изменения в альбомах (10-3600 секунд)",
"telegram_bot_token": "Токен бота для отправки уведомлений в Telegram",
"telegram_cache_ttl": "Сколько хранить ID загруженных файлов для повторной отправки без загрузки (1-168 часов, по умолчанию: 48)",
"quiet_hours_start": "Время начала тихих часов (формат ЧЧ:ММ, например 22:00). Уведомления будут поставлены в очередь. Оставьте пустым для отключения.",
"quiet_hours_end": "Время окончания тихих часов (формат ЧЧ:ММ, например 08:00). Уведомления из очереди будут отправлены в это время."
"telegram_cache_ttl": "Сколько хранить ID загруженных файлов для повторной отправки без загрузки (1-168 часов, по умолчанию: 48)"
}
}
}
@@ -257,9 +249,13 @@
"name": "Действие в чате",
"description": "Действие для отображения во время обработки (typing, upload_photo, upload_video, upload_document). Оставьте пустым для отключения."
},
"ignore_quiet_hours": {
"name": "Игнорировать тихие часы",
"description": "Отправить уведомление немедленно, даже во время тихих часов. По умолчанию уведомления ставятся в очередь и отправляются по окончании тихих часов."
"quiet_hours_start": {
"name": "Начало тихих часов",
"description": "Время начала тихих часов (формат ЧЧ:ММ, например 22:00). Уведомления в этот период ставятся в очередь и отправляются по окончании. Не указывайте для немедленной отправки."
},
"quiet_hours_end": {
"name": "Конец тихих часов",
"description": "Время окончания тихих часов (формат ЧЧ:ММ, например 08:00). Уведомления из очереди будут отправлены в это время."
}
}
}