diff --git a/Common/Immich Album Watcher/blueprint.yaml b/Common/Immich Album Watcher/blueprint.yaml index 6dd039d..ce06911 100644 --- a/Common/Immich Album Watcher/blueprint.yaml +++ b/Common/Immich Album Watcher/blueprint.yaml @@ -147,7 +147,7 @@ blueprint: name: "Assets Added Message" description: > Message sent when assets are added to an album. - Variables: `{album_name}`, `{album_url}`, `{added_count}`, `{people}`, `{assets}`, `{video_warning}`, `{common_date}`, `{common_location}` + Variables: `{album_name}`, `{album_url}`, `{album_created}`, `{album_updated}`, `{added_count}`, `{people}`, `{assets}`, `{video_warning}`, `{common_date}`, `{common_location}` default: "📷 {added_count} new photo(s) added to album \"{album_name}\"{common_date}{common_location}.{people}{assets}{video_warning}" selector: text: @@ -157,7 +157,7 @@ blueprint: name: "Assets Removed Message" description: > Message sent when assets are removed from an album. - Variables: `{album_name}`, `{album_url}`, `{removed_count}` + Variables: `{album_name}`, `{album_url}`, `{album_created}`, `{album_updated}`, `{removed_count}` default: "🗑️ {removed_count} photo(s) removed from album \"{album_name}\"." selector: text: @@ -198,7 +198,7 @@ blueprint: name: "Image Asset Template" description: > Template for IMAGE assets in the list. Also used for Telegram media captions. - Variables: `{filename}`, `{description}`, `{type}`, `{created}`, `{created_if_unique}`, `{owner}`, `{url}`, `{download_url}`, `{photo_url}`, `{playback_url}`, `{people}`, `{album_name}`, `{is_favorite}`, `{rating}`, `{location}`, `{location_if_unique}`, `{city}`, `{state}`, `{country}` + Variables: `{filename}`, `{description}`, `{type}`, `{created}`, `{created_if_unique}`, `{owner}`, `{url}`, `{download_url}`, `{photo_url}`, `{playback_url}`, `{people}`, `{album_name}`, `{album_created}`, `{album_updated}`, `{is_favorite}`, `{rating}`, `{location}`, `{location_if_unique}`, `{city}`, `{state}`, `{country}` default: "\n • 🖼️ {filename}" selector: text: @@ -208,7 +208,7 @@ blueprint: name: "Video Asset Template" description: > Template for VIDEO assets in the list. Also used for Telegram media captions. - Variables: `{filename}`, `{description}`, `{type}`, `{created}`, `{created_if_unique}`, `{owner}`, `{url}`, `{download_url}`, `{photo_url}`, `{playback_url}`, `{people}`, `{album_name}`, `{is_favorite}`, `{rating}`, `{location}`, `{location_if_unique}`, `{city}`, `{state}`, `{country}` + Variables: `{filename}`, `{description}`, `{type}`, `{created}`, `{created_if_unique}`, `{owner}`, `{url}`, `{download_url}`, `{photo_url}`, `{playback_url}`, `{people}`, `{album_name}`, `{album_created}`, `{album_updated}`, `{is_favorite}`, `{rating}`, `{location}`, `{location_if_unique}`, `{city}`, `{state}`, `{country}` default: "\n • 🎬 {filename}" selector: text: @@ -469,7 +469,7 @@ blueprint: name: Album Item Template description: > Template for each album in the summary list. - Variables: `{album_name}`, `{album_id}`, `{album_url}` + Variables: `{album_name}`, `{album_id}`, `{album_url}`, `{album_created}`, `{album_updated}` default: "\n • {album_name}: {album_url}" selector: text: @@ -629,9 +629,10 @@ blueprint: name: Message Template description: > Message template for scheduled asset notifications. - Variables: `{album_name}`, `{album_url}`, `{asset_count}`, `{assets}`, `{common_date}`, `{common_location}`. + Variables: `{album_name}`, `{album_url}`, `{album_created}`, `{album_updated}`, `{asset_count}`, `{assets}`, `{common_date}`, `{common_location}`. `{common_date}` shows the date when all assets share the same date. `{common_location}` shows the location when all assets share the same location. + `{album_created}` and `{album_updated}` are empty in combined mode. default: "📸 Here are some photos from album \"{album_name}\":{assets}" selector: text: @@ -842,6 +843,33 @@ variables: event_old_name: "{{ trigger.event.data.old_name | default('') if trigger.event is defined else '' }}" event_new_name: "{{ trigger.event.data.new_name | default('') if trigger.event is defined else '' }}" + # Album dates (look up from entity using event_album_id) + # Find the entity that has this album ID and get its created_at/updated_at attributes + event_album_entity: > + {% if trigger.event is defined %} + {% for entity_id in album_id_entities %} + {% if states(entity_id) == event_album_id %} + {{ entity_id }} + {% endif %} + {% endfor %} + {% endif %} + event_album_created: > + {% if event_album_entity | length > 0 %} + {% set created_attr = state_attr(event_album_entity | trim, 'created_at') | default('', true) %} + {% set created_dt = created_attr | as_datetime(none) if created_attr is string and created_attr | length > 0 else none %} + {{ created_dt.strftime(date_format) if created_dt else '' }} + {% else %} + {{ '' }} + {% endif %} + event_album_updated: > + {% if event_album_entity | length > 0 %} + {% set updated_attr = state_attr(event_album_entity | trim, 'updated_at') | default('', true) %} + {% set updated_dt = updated_attr | as_datetime(none) if updated_attr is string and updated_attr | length > 0 else none %} + {{ updated_dt.strftime(date_format) if updated_dt else '' }} + {% else %} + {{ '' }} + {% endif %} + # --------------------------------------------------------------------------- # Computed Values # --------------------------------------------------------------------------- @@ -959,6 +987,8 @@ variables: | replace('{playback_url}', asset.playback_url | default('')) | replace('{people}', (asset.people | default([])) | join(', ')) | replace('{album_name}', event_album_name) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{is_favorite}', is_favorite) | replace('{rating}', rating) | replace('{location}', formatted_location) @@ -1048,7 +1078,7 @@ variables: {% endif %} # Format the albums list for periodic summary - # Reads album name and share URL from album ID entity's attributes + # Reads album name, share URL, and dates from album ID entity's attributes periodic_albums_list: > {% set ns = namespace(items = '') %} {% for i in range(album_id_entities | length) %} @@ -1059,10 +1089,18 @@ variables: {% set name = name_attr if name_attr not in [none, '', 'unknown', 'unavailable'] else id %} {% set url_attr = state_attr(entity_id, 'share_url') %} {% set url = url_attr if url_attr not in [none, 'unknown', 'unavailable'] else '' %} + {% set created_attr = state_attr(entity_id, 'created_at') | default('', true) %} + {% set created_dt = created_attr | as_datetime(none) if created_attr is string and created_attr | length > 0 else none %} + {% set album_created = created_dt.strftime(date_format) if created_dt else '' %} + {% set updated_attr = state_attr(entity_id, 'updated_at') | default('', true) %} + {% set updated_dt = updated_attr | as_datetime(none) if updated_attr is string and updated_attr | length > 0 else none %} + {% set album_updated = updated_dt.strftime(date_format) if updated_dt else '' %} {% set item = periodic_album_template | replace('{album_name}', name) | replace('{album_id}', id) - | replace('{album_url}', url) %} + | replace('{album_url}', url) + | replace('{album_created}', album_created) + | replace('{album_updated}', album_updated) %} {% set ns.items = ns.items ~ item %} {% endif %} {% endfor %} @@ -1187,6 +1225,14 @@ action: current_album_url: > {% set url_attr = state_attr(current_album_entity, 'share_url') %} {{ url_attr if url_attr not in [none, 'unknown', 'unavailable'] else '' }} + current_album_created: > + {% set created_attr = state_attr(current_album_entity, 'created_at') | default('', true) %} + {% set created_dt = created_attr | as_datetime(none) if created_attr is string and created_attr | length > 0 else none %} + {{ created_dt.strftime(date_format) if created_dt else '' }} + current_album_updated: > + {% set updated_attr = state_attr(current_album_entity, 'updated_at') | default('', true) %} + {% set updated_dt = updated_attr | as_datetime(none) if updated_attr is string and updated_attr | length > 0 else none %} + {{ updated_dt.strftime(date_format) if updated_dt else '' }} # Build service data dynamically (omit optional params when not set) - variables: @@ -1307,6 +1353,8 @@ action: | replace('{playback_url}', asset.playback_url | default('')) | replace('{people}', (asset.people | default([])) | join(', ')) | replace('{album_name}', current_album_name) + | replace('{album_created}', current_album_created) + | replace('{album_updated}', current_album_updated) | replace('{is_favorite}', is_favorite) | replace('{rating}', rating) | replace('{location}', formatted_location) @@ -1323,6 +1371,8 @@ action: {{ scheduled_assets_message_template | replace('{album_name}', current_album_name) | replace('{album_url}', current_album_url) + | replace('{album_created}', current_album_created) + | replace('{album_updated}', current_album_updated) | replace('{asset_count}', fetched_asset_count | string) | replace('{common_date}', sched_common_date) | replace('{common_location}', sched_common_location) @@ -1555,6 +1605,8 @@ action: | replace('{playback_url}', asset.playback_url | default('')) | replace('{people}', (asset.people | default([])) | join(', ')) | replace('{album_name}', combined_album_names) + | replace('{album_created}', '') + | replace('{album_updated}', '') | replace('{is_favorite}', is_favorite) | replace('{rating}', rating) | replace('{location}', formatted_location) @@ -1571,6 +1623,8 @@ action: {{ scheduled_assets_message_template | replace('{album_name}', combined_album_names) | replace('{album_url}', '') + | replace('{album_created}', '') + | replace('{album_updated}', '') | replace('{asset_count}', combined_asset_count | string) | replace('{common_date}', comb_common_date) | replace('{common_location}', comb_common_location) @@ -1720,6 +1774,8 @@ action: {%- set msg_video_warning = telegram_video_warning_template if (send_telegram_media and has_videos_in_assets and telegram_video_warning_template | length > 0) else '' -%} {{ tpl | replace('{album_name}', event_album_name) | replace('{album_url}', event_album_url) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{added_count}', filtered_added_count | string) | replace('{people}', people_list) | replace('{assets}', assets_list) @@ -1745,6 +1801,8 @@ action: {% set tpl = message_assets_removed_template %} {{ tpl | replace('{album_name}', event_album_name) | replace('{album_url}', event_album_url) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{removed_count}', event_removed_count | string) }} - service: notify.send_message @@ -1774,6 +1832,8 @@ action: {%- set chg_video_warning = telegram_video_warning_template if (send_telegram_media and has_videos_in_assets and telegram_video_warning_template | length > 0) else '' -%} {{ tpl | replace('{album_name}', event_album_name) | replace('{album_url}', event_album_url) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{added_count}', filtered_added_count | string) | replace('{people}', people_list) | replace('{assets}', assets_list) @@ -1798,6 +1858,8 @@ action: {% set tpl = message_assets_removed_template %} {{ tpl | replace('{album_name}', event_album_name) | replace('{album_url}', event_album_url) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{removed_count}', event_removed_count | string) }} - service: notify.send_message @@ -1954,6 +2016,8 @@ action: {%- set tg_video_warning = telegram_video_warning_template if (send_telegram_media and has_videos_in_assets and telegram_video_warning_template | length > 0) else '' -%} {{ tpl | replace('{album_name}', event_album_name) | replace('{album_url}', event_album_url) + | replace('{album_created}', event_album_created) + | replace('{album_updated}', event_album_updated) | replace('{added_count}', filtered_added_count | string) | replace('{people}', people_list) | replace('{assets}', assets_list) diff --git a/manifest.json b/manifest.json index c031803..7a23fa9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,3 +1,3 @@ { - "version": "1.22.10" + "version": "1.23.0" }