So, I came up with a ‘solution’ that works for me. I can complete my whole shopping list by pushing an actionable push notification. Just what I wanted. Here’s my workaround:
Create a sensor of the shopping list (found somewhere on this forum):
#!/usr/local/bin/python
# coding: utf8
import json
with open('/config/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
content = u"Boodschappen:\n"
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\n"
print(content)
Name this shopping_list.py
and place it in your /config
folder.
This creates a list with all items on your shopping list. I let Home Assistant send me this list when I enter the zone of my local supermarket.
Add this to your config file:
ios:
push:
categories:
- name: Empty Shopping List
identifier: 'empty_shopping_list'
actions:
- identifier: 'EMPTY'
title: 'Empty'
destructive: true
- identifier: 'KEEP'
title: 'Keep'
sensor:
- platform: command_line
name: shopping_list
command: python3 /config/shopping_list.py
automation:
# Action when triggering 'Empty Shopping List' button from actionable push notification
- alias: ios actionable empty
trigger:
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: EMPTY
action:
service: script.toggle
entity_id: script.empty_shopping_list
script:
# Splits the information of sensor.shopping_list and completes this item on shopping list
'empty_shopping_list':
alias: empty shopping list
sequence:
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[1] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[2] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[3] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[4] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[5] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[6] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[7] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[8] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[9] }}
- service: shopping_list.complete_item
data_template:
name: >-
{{ states.sensor.shopping_list.state.split('-')[10] }}
This works for me, and maybe someone else. The only thing that I’m left with is a completed list. Can’t find a way to delete completed items without clicking on the icon.