|
| 1 | +###################################################################### |
| 2 | +# @CCOSTAN - Follow Me on X |
| 3 | +# For more info visit https://www.vcloudinfo.com/click-here |
| 4 | +# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig |
| 5 | +# ------------------------------------------------------------------- |
| 6 | +# Notify Live Activity - Shared helper for tagged live mobile updates |
| 7 | +# Related Issue: 1598 |
| 8 | +# Sends or clears tagged live activity/live update notifications. |
| 9 | +# ------------------------------------------------------------------- |
| 10 | +# Notes: Resolves notify target from `who` similar to notify_engine. |
| 11 | +# Notes: Uses `clear_notification` plus `tag` to end a live activity. |
| 12 | +# Notes: Defaults are tuned for Powerwall outage tracking on iOS parents. |
| 13 | +###################################################################### |
| 14 | + |
| 15 | +notify_live_activity: |
| 16 | + alias: Notify Live Activity |
| 17 | + description: Send or clear a tagged live-tracking notification for supported mobile targets. |
| 18 | + mode: queued |
| 19 | + fields: |
| 20 | + who: |
| 21 | + description: Notification audience key (carlo, stacey, family, parents). |
| 22 | + example: parents |
| 23 | + tag: |
| 24 | + description: Stable notification tag used to replace or clear the live activity. |
| 25 | + example: powerwall_grid_outage |
| 26 | + title: |
| 27 | + description: Notification title. |
| 28 | + example: Power outage |
| 29 | + message: |
| 30 | + description: Notification message body. |
| 31 | + example: Grid outage in progress. Powerwall charge at 82%. |
| 32 | + icon: |
| 33 | + description: Material Design icon for the live activity. |
| 34 | + example: mdi:transmission-tower-off |
| 35 | + color: |
| 36 | + description: Hex color for the live activity icon. |
| 37 | + example: "#E65100" |
| 38 | + progress: |
| 39 | + description: Progress value for the live activity. |
| 40 | + example: 82 |
| 41 | + progress_max: |
| 42 | + description: Maximum progress value. |
| 43 | + example: 100 |
| 44 | + chronometer: |
| 45 | + description: Enable the live chronometer. |
| 46 | + example: true |
| 47 | + when: |
| 48 | + description: Unix timestamp in seconds for the chronometer anchor. |
| 49 | + example: 1742846400 |
| 50 | + when_relative: |
| 51 | + description: Treat the `when` value as relative seconds instead of an absolute timestamp. |
| 52 | + example: false |
| 53 | + clear: |
| 54 | + description: Set true to clear the existing live activity for the tag. |
| 55 | + example: false |
| 56 | + sequence: |
| 57 | + - variables: |
| 58 | + normalized_who: "{{ who | default('parents', true) | string | lower | trim }}" |
| 59 | + notify_service: >- |
| 60 | + {% if normalized_who == 'stacey' %} |
| 61 | + notify.mobile_app_stacey_iphone11 |
| 62 | + {% elif normalized_who == 'carlo' %} |
| 63 | + notify.mobile_app_carlo_maxpro |
| 64 | + {% elif normalized_who == 'family' %} |
| 65 | + notify.ios_family |
| 66 | + {% else %} |
| 67 | + notify.ios_parents |
| 68 | + {% endif %} |
| 69 | + notification_tag: "{{ tag | default('live_activity', true) | string | trim }}" |
| 70 | + clear_flag: "{{ clear | default(false, true) | bool }}" |
| 71 | + live_title: "{{ title | default('Live update', true) | string | trim }}" |
| 72 | + live_message: "{{ message | default('Live update in progress.', true) | string | trim }}" |
| 73 | + live_icon: "{{ icon | default('mdi:progress-helper', true) | string | trim }}" |
| 74 | + live_color: "{{ color | default('#2196F3', true) | string | trim }}" |
| 75 | + live_progress: "{{ progress | default(-1, true) | int(-1) }}" |
| 76 | + live_progress_max: "{{ progress_max | default(100, true) | int(100) }}" |
| 77 | + live_chronometer: "{{ chronometer | default(false, true) | bool }}" |
| 78 | + live_when: "{{ when | default(0, true) | int(0) }}" |
| 79 | + live_when_relative: "{{ when_relative | default(false, true) | bool }}" |
| 80 | + - condition: template |
| 81 | + value_template: "{{ notification_tag != '' }}" |
| 82 | + - choose: |
| 83 | + - conditions: |
| 84 | + - condition: template |
| 85 | + value_template: "{{ clear_flag }}" |
| 86 | + sequence: |
| 87 | + - service: "{{ notify_service }}" |
| 88 | + data: |
| 89 | + message: clear_notification |
| 90 | + data: |
| 91 | + tag: "{{ notification_tag }}" |
| 92 | + default: |
| 93 | + - service: "{{ notify_service }}" |
| 94 | + data: |
| 95 | + title: "{{ live_title }}" |
| 96 | + message: "{{ live_message }}" |
| 97 | + data: |
| 98 | + tag: "{{ notification_tag }}" |
| 99 | + group: "{{ notification_tag }}" |
| 100 | + alert_once: true |
| 101 | + live_activity: true |
| 102 | + live_update: true |
| 103 | + notification_icon: "{{ live_icon }}" |
| 104 | + notification_icon_color: "{{ live_color }}" |
| 105 | + progress: "{{ live_progress }}" |
| 106 | + progress_max: "{{ live_progress_max }}" |
| 107 | + chronometer: "{{ live_chronometer }}" |
| 108 | + when: "{{ live_when }}" |
| 109 | + when_relative: "{{ live_when_relative }}" |
0 commit comments