Closed agmorpheus closed 6 months ago
I don't personally use the example automation so I can't test this, but I can try to point you in the right direction. In the future, the Home Assistant forums will usually be more helpful for general automation questions.
You might be able to do something like this
alias: Universal List Sync
description: Sync any specified list with Anylist
trigger:
- platform: event
event_type: call_service
event_data:
domain: todo
service: add_item
variables:
item_name: "{{ trigger.event.data.service_data.item }}"
list_name: "{{ state_attr(trigger.event.data.service_data.entity_id[0], 'friendly_name') }}"
list_entity_id: "{{ trigger.event.data.service_data.entity_id[0] }}"
prefix: "todo.google_keep_"
list_key: "{{ list_entity_id.replace(prefix, '') }}"
condition: []
action:
- service: notify.persistent_notification
data:
message: "'{{ item_name }}' was just added to the '{{ list_name }}' list."
- service: todo.add_item
data:
item: "{{ item_name }}"
target:
entity_id: "todo.anylist_alexa_{{ list_key }}"
- service: todo.update_item
target:
entity_id: "{{ list_entity_id }}"
data:
status: completed
item: "{{ item_name }}"
mode: parallel
max: 50
The key part is this
prefix: "todo.google_keep_"
list_key: "{{ list_entity_id.replace(prefix, '') }}"
Basically, you would have to rename the entities names so the suffixes match between Google Keep Sync and Anylist Alexa. So they would all keep their prefixes (all Keep todo entities start with todo.googlekeep and all Anylist with todo.anylistalexa) and then make sure that everything that comes after todo.googlekeep would match up with the list you want to sync to with anylist_alexa.
So example:
You want todo.google_keep_sync_shopping_list to sync to Anylist, you would name it todo.anylist_alexa_shopping_list. You want todo.google_keep_sync_grocery_list to sync, you name the Anylist todo.anylist_alexa_grocery_list. Again, I can't test this, but hopefully this helps out.
Thanks for your help. I got it working. I also added a condition, that the automation is not applied again for the new item on the Anylist List
Thanks for this great integration.
I have a question. Is it possible to make your sample automation more generic? I have several list that I want to sync with anylist. I think it is not the best solution to create for each list pair a seperate automation.
The "shopping_list" string of the entities needs to be a variable. Maybe it possible to use the list_entity_id somehow. But I dont know how? I am new to HA, maybe you have an idea?
Thanks!