Hi everyone!
I want to share simple HA automation for shopping list notifications that buffers multiple item updates and sends a single combined notification instead of one notification per item. This is especially useful when adding items via Assist
, which often send multiple rapid updates.
Key features:
- Buffers all shopping list changes for 15 seconds, then sends one notification with all changes.
- Tracks the following actions:
Added
Completed
Restored (unchecked)
Removed (only if not completed)
- Capitalizes item names for better readability.
- Includes a notification button “VIEW FULL LIST” that opens the shopping list in the HA app.
- MDI
notification_icon
- Adds custom
notification channel
to set a specific sound or behavior on Android devices.
Important note:
Currently, the shopping_list_updated
event does not support user IDs, so this notification cannot be filtered per user.
alias: Shopping List Update Notification
description: >-
Groups multiple shopping list updates into a single notification by buffering
changes over a short period.
triggers:
- alias: On shopping list change
event_type: shopping_list_updated
trigger: event
variables:
action: "{{ trigger.event.data.action }}"
completed: "{{ trigger.event.data.item.complete }}"
item: "{{ trigger.event.data.item.name | capitalize }}"
conditions:
- alias: Valid action check
condition: template
value_template: "{{ valid_actions.get((action, completed), false) }}"
actions:
- alias: Append to buffer
action: input_text.set_value
data:
value: >
{{ action_label ~ ": " ~ item if buffer in [none, ''] else buffer ~ "; "
~ action_label ~ ": " ~ item }}
target:
entity_id: input_text.shopping_list_buffer
- alias: Wait for additional input or timeout
continue_on_timeout: true
timeout: "00:00:15"
wait_for_trigger:
- alias: On next shopping list event
event_type: shopping_list_updated
trigger: event
- alias: Send mobile notification
action: notify.mobile_app_your_phone
data:
title: đź›’ {{ list_name }} updated
message: |
{{ states('input_text.shopping_list_buffer').replace(';','\n') }}
data:
clickAction: /todo
notification_icon: mdi:cart
url: /todo
actions:
- action: URI
title: VIEW FULL LIST
uri: /todo
- alias: Clear buffer
action: input_text.set_value
data:
value: ""
target:
entity_id: input_text.shopping_list_buffer
mode: restart
variables:
valid_actions: |
{{ {
('add', false): true,
('update', true): true,
('update', false): true,
('remove', false): true
} }}
action_label: |
{{ {
('add', false): '🆕 Added',
('update', true): 'âś… Completed',
('update', false): '♻️ Restored',
('remove', false): 'â›” Removed'
}.get((action, completed)) }}
buffer: "{{ states('input_text.shopping_list_buffer') }}"
list_name: "{{ state_attr('todo.shopping_list', 'friendly_name') }}"
Dependencies:
- An input_text helper named
shopping_list_buffer
(with max length 255) to store buffered item updates.