Created
May 31, 2024 12:23
-
-
Save MichaelThomasMPT/f467d99020bb9fa3d8ebc8a521c0ed8f to your computer and use it in GitHub Desktop.
A script and a couple of automations to allow Home Assistant to transfer todo/shopping list items from one list to another (eg. Google Keep to Todoist)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script: | |
todo_list_move_incomplete_items: | |
fields: | |
source_list: | |
description: "Source list to copy from" | |
dest_list: | |
description: "Destination list to copy to" | |
subtext: | |
description: "The non-title text to add to the items" | |
due_today: | |
description: "Whether the task should have today as a due date" | |
default: "False" | |
#FIXME do something with this field, not in use yet | |
sequence: | |
- service: todo.get_items | |
data: | |
status: | |
- needs_action | |
response_variable: items | |
target: | |
entity_id: "{{ source_list }}" | |
- repeat: | |
for_each: > | |
{% set list_name = items.keys() | list %} | |
{{ items[list_name[0]]['items'] }} | |
sequence: | |
- if: | |
- alias: "Due date is set" | |
condition: template | |
value_template: "{{ due_today == 'True' }}" | |
then: | |
- service: todo.add_item | |
data: | |
item: > | |
{{ repeat.item.summary }} | |
description: > | |
{{ subtext }} | |
due_date: "{{ now().strftime('%Y-%m-%d') }}" | |
target: | |
entity_id: "{{ dest_list }}" | |
else: | |
- service: todo.add_item | |
data: | |
item: > | |
{{ repeat.item.summary }} | |
description: > | |
{{ subtext }} | |
target: | |
entity_id: "{{ dest_list }}" | |
- service: todo.remove_item | |
data: | |
item: > | |
{{ repeat.item.summary }} | |
target: | |
entity_id: "{{ source_list }}" | |
automation: | |
- alias: Todo List - Transfer Google Tasks Todo List | |
id: todolist_transfer_google_tasks_todo_list | |
trigger: | |
- id: "regular_trigger" | |
platform: state | |
entity_id: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
- id: "fallback_trigger" | |
platform: time_pattern | |
minutes: "/10" | |
condition: | |
- alias: "List isn't empty" | |
condition: not | |
conditions: | |
- condition: state | |
entity_id: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
state: "0" | |
action: | |
- service: script.todo_list_move_incomplete_items | |
data: | |
source_list: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
dest_list: todo.inbox #Replace this with your target todo list, eg. Todoist etc. | |
subtext: "Imported from Google Tasks" | |
due_today: "True" | |
- alias: Todo List - Transfer Google Tasks Todo List | |
id: todolist_transfer_google_tasks_todo_list | |
trigger: | |
- id: "regular_trigger" | |
platform: state | |
entity_id: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
- id: "fallback_trigger" | |
platform: time_pattern | |
minutes: "/10" | |
condition: | |
- alias: "List isn't empty" | |
condition: not | |
conditions: | |
- condition: state | |
entity_id: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
state: "0" | |
action: | |
- service: script.todo_list_move_incomplete_items | |
data: | |
source_list: todo.google_keep_to_do #Replace this with your Google Keep todo list | |
dest_list: todo.inbox #Replace this with your target todo list, eg. Todoist etc. | |
subtext: "Imported from Google Tasks" | |
due_today: "True" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment