mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
Add details of shopping_list_updated events (#24080)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
8eee209284
commit
650b7a6ebd
@ -59,18 +59,33 @@ Clear completed items from the shopping list.
|
||||
|
||||
## Using in Automations
|
||||
|
||||
The simplest way to use the shopping list with automations (e.g., when entering a zone with shops) is to create a notification that can be clicked to open the shopping list.
|
||||
A `shopping_list_updated` event is triggered when items in the list are modified, with the following data payload attached to it. This can be used to trigger automations such as sending a push notification when someone adds an item to the shopping list, which when clicked, will open the list.
|
||||
|
||||
| Data payload attribute | Description |
|
||||
|------------------------|--------------------------------------------------------------------------------------------------------------------|
|
||||
| `action` | What action was taken on the item. Either `add` for a new item being added, or `update` for an item being updated. |
|
||||
| `item` | A dictionary containing details of the item that was updated. |
|
||||
| `item.id` | A unique ID for this item |
|
||||
| `item.name` | The text attached to the item, for example `Milk` |
|
||||
| `item.complete` | A boolean indicated whether the item has been marked as complete. |
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
- service: notify.notify
|
||||
data:
|
||||
title: "Time to shop?"
|
||||
message: "Click to open the shopping list"
|
||||
alias: "Notify on new shopping list item"
|
||||
trigger:
|
||||
- platform: event
|
||||
event_type: shopping_list_updated
|
||||
event_data:
|
||||
action: "add"
|
||||
action:
|
||||
- service: notify.notify
|
||||
data:
|
||||
clickAction: "/shopping-list"
|
||||
url: "/shopping-list"
|
||||
message: "{{ trigger.event.data.item.name }} has been added to the shopping list"
|
||||
data:
|
||||
clickAction: "/shopping-list"
|
||||
url: "/shopping-list"
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user