I am wondering if anyone has some Ideas or expertise to create an automation to export a to-do list?
My thoughts are
Get the list items with the todo.get_items service
Use the result of this service to export the items with a notify service.
I have successfully created a notify service that creates a File using the file notify function. File - Home Assistant
I am just unaware on how to get the items to populate the file.
I assume I should be able to do this with a response variable but I am not sure how this works.
Any help would be greatly appreciated.
I had used something similar in the past, so not sure if it’s fully up to latest format, but it may help you…
Here is the notify service defined in yaml:
You would need to adjust with your variables of course.
The file will end up in your config folder.
I think the above appends data, so doesn’t erase previous data, but please check as it has been a long while since I’ve used it.
edit: forgot to mention … the variables part - yes, use response variables…
This is definitely on the same path as I am investigating. I have the notify portion working, do you have more of an example of getting the response variable the_list to “seed” the notify service?
action:
service: notify.list_file_notify
data_template:
message: |-
{%- for item in the_list['todo.hass_ideas']['items'] %}
{{ item.summary }}
{%- endfor %}
Edit: this last part came from another post, so edit your todo. … part as needed.
Here is a link to that post - may be more helpful Help, how to use: todo.get_items
@eftimg
Thank you so much for your responses. I now have this working/
I have done the following.
Created an “Around the house” list in my to-do.
Created a list notify in my configuration.yaml
notify:
- platform: file
name: List Export
filename: To-Do.List
Created the following automation (trigger is for testing only).
I tried to replicate what is described in this thread, unfortunately today, with version 2025.02, it SEEMS it is no longer possible to create notify from yaml, and I have not understood how to do it from UI.
But I did not let myself be discouraged, and for my use case (having all the lists exported and easy to send to keep them offline when we go shopping) I created this script, startable with a button from UI:
alias: Export List
sequence:
- action: todo.get_items
metadata: {}
data:
status: needs_action
target:
entity_id:
- todo.carne_pesce
- todo.colazione
response_variable: mylist
- action: notify.persistent_notification
metadata: {}
data:
title: Lista Spesa Export
message: |-
{%- for todo_key, todo_value in mylist.items() %}
{%- if todo_value['items'] %}
### {{ todo_key.split('.')[1] }}
{%- for item in todo_value['items'] %}
- {{ item.summary }}
{%- endfor %}
{%- endif %}
---
{%- endfor %}
description: ""
(obviously adapt the entity_id with your lists)
Using this code you can generate a list between notifications and do “Select all → copy” to take it wherever you want.
If anyone knows how to send it directly on whatsapp or telegram that would be great!
In the meantime I’m happy to share my work with you
Note, after import, is possible edit the first part with UI editor!