Export To-Do List

I am wondering if anyone has some Ideas or expertise to create an automation to export a to-do list?
My thoughts are

  1. Get the list items with the todo.get_items service
  2. 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:

notify 21:
  - platform: file
    name: List-File-Notify
    filename: List-File-Notify.txt
    timestamp: false

And here is the action part example from the automation:

  - service: notify.list_file_notify
      message: >-
        {{ as_timestamp(states.sensor.example_temperature.last_changed) |
        timestamp_local }}

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… :slight_smile:

  - service: calendar.get_events
        - calendar.my_cal
      device_id: []
      area_id: []
        hours: 30
        minutes: 0
        seconds: 0
    response_variable: the_list

The above would be similar to your to-do list, then use the response variable to seed into the notify service (may need to use data_template:

      value: |-
        {%- PROCESS YOUR List variable here %}

Sorry don’t have better example, but I hope it will point you in the right direction

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?

Try something like this …

    service: notify.list_file_notify
      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 :slight_smile: Help, how to use: todo.get_items

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

  - platform: file
    name: List Export
    filename: To-Do.List

Created the following automation (trigger is for testing only).

alias: Export List
description: ""
  - platform: numeric_state
      - input_number.automation_test_number
    above: 5
condition: []
  - service: todo.get_items
    metadata: {}
      status: needs_action
    response_variable: mylist
      entity_id: todo.around_the_house
  - service: notify.list_export
      message: |-
        {%- for item in mylist['todo.around_the_house']['items'] %}
          {{ item.summary }}
        {%- endfor %}
mode: single

I now have a file created that contains the items in my list.
Thanks again!

1 Like

Awesome - glad it’s working for you.