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
|
## 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 %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- service: notify.notify
|
alias: "Notify on new shopping list item"
|
||||||
data:
|
trigger:
|
||||||
title: "Time to shop?"
|
- platform: event
|
||||||
message: "Click to open the shopping list"
|
event_type: shopping_list_updated
|
||||||
|
event_data:
|
||||||
|
action: "add"
|
||||||
|
action:
|
||||||
|
- service: notify.notify
|
||||||
data:
|
data:
|
||||||
clickAction: "/shopping-list"
|
message: "{{ trigger.event.data.item.name }} has been added to the shopping list"
|
||||||
url: "/shopping-list"
|
data:
|
||||||
|
clickAction: "/shopping-list"
|
||||||
|
url: "/shopping-list"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user