I combined the trigger I found here How to send notification when item added to a Todo list? - #12 by Didgeridrew with the automation here Move incomplete items between todo lists - #2 by my.spider.died to create an automation that when I mark an item as complete on my Long Term To Do list it moves to Weekly Long Term Task to do list
alias: "To-do list transfer "
description: ""
trigger:
- platform: event
event_type: call_service
event_data:
domain: todo
service: update_item
service_data:
status: completed
variables:
list_name: >
{{ state_attr((trigger.event.data.service_data.entity_id)[0],
'friendly_name') }}
item: "{{ trigger.event.data.service_data.item | title }}"
user_name: >
{% set uid = trigger.event.context.user_id %}
{% set user = None %}
{% set matching_users = states.person | selectattr('attributes.user_id',
'==', uid) | list %}
{% set user = matching_users | first if matching_users | length > 0 else
"System" %}
{{ user if user == "System" else
state_attr(user.entity_id,"friendly_name") }}
condition: []
action:
- if:
- condition: template
value_template: "{{list_name == 'Dan Long Term List'}}"
enabled: true
then:
- service: todo.get_items
data:
status:
- completed
target:
entity_id:
- todo.long_term_to_do
response_variable: items
- repeat:
for_each: >
{% set list_name = items.keys() | list %} {{
items[list_name[0]]['items'] }}
sequence:
- service: todo.add_item
data:
item: |
{{ repeat.item.summary }}
target:
entity_id:
- todo.dan_s_long_term_task_for_the_week
- service: notify.mobile_app_pixel_5
metadata: {}
data:
message: success!
- service: todo.remove_completed_items
metadata: {}
data: {}
target:
entity_id: todo.long_term_to_do
enabled: true
mode: single
I am able to get it to trigger but the repeat section doesn’t activate. If I make an automation of just that section it works fine. For some reason using this trigger prevents it from working.
Bonus points if I can remove the repeat all together as I only need the automation to trigger for one item at a time.
Thank you!