The new todo list feature is great!
I would like to have recurring checklist which get triggered by an automation.
Basically I would like to simply check or uncheck all items on an existing todo list. Or have an action which resets all items on a list.
I tried using wildcards in the “To-do list: Update to-do list item” action, but without success. It seems, that I have to create a “call service” action for each item on the list, which seems redundant.
Is there a better way to do this?
Thanks!
You should re-tag this as a feature request.
I would love to see this too.
I currently have a recipe generator that uses the OpenAI Conversation agent to generate and save recipes, and I’d love to use a todo list to display the ingredients. However, as it is, I can’t really use the todo entities for this, for a few reasons.
OpenAI returns each recipe as a JSON object, which is parsed and saved as a key in the “recipes” attribute of a template sensor, sensor.recipes
.
View the prompt (Top P: 1; Temp: 0.3)
You are a recipe generator.The user will ask for a recipe by name. You must provide your response as a JSON object with the following format:
{
"name": "Banana bread",
"ingredients": [
"180g all-purpose flour",
"2 to 3 very ripe bananas",
"150g sugar",
"1 large egg",
"75g butter, melted",
"1 teaspoon baking soda",
"1 teaspoon vanilla extract",
"a pinch of salt"
],
"instructions": [
"Preheat oven to 350°F (175°C). Grease/flour a 9x5\" loaf pan.",
"Mash the bananas in a large bowl.",
"Mix in the egg, melted butter, sugar and vanilla.",
"In another bowl, whisk the flour, baking soda and salt.",
"Gradually add the dry mix to the batter, stirring until just combined.",
"Pour the batter into the pan, spreading it evenly.",
"Bake for 50-60 minutes, then let it cool in the pan for 10 minutes.",
"Transfer to a wire rack to cool completely before slicing."
],
"notes": "Leave blank except to communicate an error or important detail that doesn\u0027t fit elsewhere."
}
Where practical, prefer weights (grams) over volumes. Your response will be consumed by an API that strips out the JSON object.
I use an input_text to collect the prompts and an automation to process them, and I display the ingredients/instructions in an HTML card.
These are the features I’d need/like from the todo entities:
- ability to set/clear the whole list at once
- ability to make the items read-only in the frontend (especially if this reduces the vertical height when displayed in the frontend)
- ability to create new todo entities via service call (this would allow me to save each recipe as a separate todo entity)
I do not understand that you have to specify the name of an item in the todo-list.
I really need a wildcard as well. You have a vote!
Absolutely necessary! My use case is that I have lists of daily chores that my kids can check off, and without an option to reset all, I have to modify YAML & automations every time I want to add a chore to their list.
+1 here. Using to-do’s as repeatable action lists and being able to reset all completed items in an automation would be fantastic.
This is no real fix, but I wrote myself a script that seems to be working.
It checks if any items in my todo list are marked as completed and then changes their status to needs_action one by one.
Maybe not the most elegant, but seems to do the trick
script:
meals_reset_status:
alias: Meals Reset Status
sequence:
- service: todo.get_items #check if there are completed tasks and create the necessary variable
target:
entity_id: todo.meals
data:
status: completed
response_variable: mymeals
- repeat:
while:
- condition: template
value_template: "{{ mymeals['todo.meals']['items'] | map(attribute='summary') | list | count != 1 }}" #check that at least one item is completed (must be 1 and not 0 because the following sequence will be executed one last time)
sequence:
- service: todo.get_items
target:
entity_id: todo.meals
data:
status: completed
response_variable: mymeals #update the variable to prevent infinite loop
- service: todo.update_item
target:
entity_id: todo.meals
data:
item: "{{ mymeals['todo.meals']['items'] | map(attribute='summary') | first }}"
status: "needs_action"
mode: single
Thanks for this, definitely helped me out. I ended up refining the code a little bit so that it uses the size of the response variable to set the count for the repeat and then use the repeat.index
variable to loop through the items in the list. I thought I would post it here to help anyone that comes across this post.
trigger:
- platform: time
at: "01:00:00"
condition: []
action:
- service: todo.get_items
metadata: {}
data:
status:
- completed
response_variable: completed
target:
entity_id: todo.chores
- repeat:
count: "{{ completed['todo.chores']['items'] | count }}"
sequence:
- service: todo.update_item
metadata: {}
data:
status: needs_action
item: "{{completed['todo.chores']['items'][repeat.index-1]['summary']}}"
target:
entity_id: todo.chores
mode: single
Nice, thank you for the improvement
I needed some more scyripts, so I created
- one to add a batch from an array. Useful if you have a list of items somewhere and want to enter them all at once. I had ~150 recipes that I wanted to add and was not willing to add one by one ^^.
- one to delete all list items (independent of status, so add status if you do not want that)
- one to reset all to
needs_action
The code can be optimized for sure.
@mccmax1395 made the first improvements and @petro optimized my addition code. Thank you both
script:
meals_batch_addition_all:
alias: Meals Batch Addition All
sequence:
- repeat:
for_each: "{{['1000 Und 1 Nacht Berberitzen Mandel Reis','Aloo Saag Indisches Spinat Curry Mit Kartoffeln']}}"
sequence:
- service: todo.add_item
data:
item: "{{ repeat.item }}"
#due_date: "2099-09-18"
target:
entity_id: todo.meals
mode: single
meals_reset_status:
alias: Meals Reset Status
sequence:
- service: todo.get_items
data:
status:
- completed
response_variable: completed
target:
entity_id: todo.meals
- repeat:
count: "{{ completed['todo.meals']['items'] | count }}"
sequence:
- service: todo.update_item
data:
status: needs_action
item: "{{completed['todo.meals']['items'][repeat.index-1]['summary']}}"
target:
entity_id: todo.meals
mode: single
meals_delete_all:
alias: Meals Delete All
sequence:
- service: todo.get_items
response_variable: all_items
target:
entity_id: todo.meals
- repeat:
count: "{{ all_items['todo.meals']['items'] | count }}"
sequence:
- service: todo.remove_item
data:
item: "{{all_items['todo.meals']['items'][repeat.index-1]['summary']}}"
target:
entity_id: todo.meals
mode: single
You still got some overcomplication in there…
script:
meals_batch_addition_all:
alias: Meals Batch Addition All
sequence:
- repeat:
for_each: "{{['1000 Und 1 Nacht Berberitzen Mandel Reis','Aloo Saag Indisches Spinat Curry Mit Kartoffeln']}}"
sequence:
- service: todo.add_item
data:
item: "{{ repeat.item }}"
#due_date: "2099-09-18"
target:
entity_id: todo.meals
mode: single
meals_reset_status:
alias: Meals Reset Status
sequence:
- service: todo.get_items
data:
status:
- completed
response_variable: completed
target:
entity_id: todo.meals
- repeat:
for_each: "{{ completed['todo.meals']['items'] }}"
sequence:
- service: todo.update_item
data:
status: needs_action
item: "{{ repeat.item.summary }}"
target:
entity_id: todo.meals
mode: single
meals_delete_all:
alias: Meals Delete All
sequence:
- service: todo.get_items
response_variable: all_items
target:
entity_id: todo.meals
- repeat:
for_each: "{{ all_items['todo.meals']['items'] }}"
sequence:
- service: todo.remove_item
data:
item: "{{ repeat.item.summary }}"
target:
entity_id: todo.meals
mode: single
Jupp, you are right. I could have used the for_each rather than count.
Nice thing is, many roads lead to Rome. But yours is definitely the motorway. Mine is more like the scenic route
If you have duplicate items in your todo list you can also use uid
- service: todo.get_items
data:
status: completed
target:
entity_id: todo.radio_stations
response_variable: completed
- repeat:
for_each: >
{{ completed['todo.radio_stations']['items'] }}
sequence:
- service: todo.update_item
data:
status: needs_action
item: >
{{ repeat.item.uid }}
target:
entity_id: todo.radio_stations
I’m going to go through the script that @petro shared above.
But just to add my voice to the feature request: a simple rollout of this feature would be massively valuable for me.
My use-case is two fold:
- Recurring chore lists
- Reminders before I leave the house and get home (do you have your wallet? Etc)
If there were a simple call to the todo entity associated with the task list that could reset all items … it would be as simple as adding a little “reset checklist” button to the end of every task where the functionality is desired.
This was extremely helpful! I was able to make an automation to reset one of two of my recurring shopping lists based on which virtual button was pressed:
alias: Refresh Shopping List
description: ""
trigger:
- platform: state
entity_id:
- input_button.reset_costco_list
to: null
id: Costco
- platform: state
entity_id:
- input_button.reset_qfc_fred_meyer_list
to: null
id: QFC/Fred Meyer
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- Costco
sequence:
- service: todo.get_items
metadata: {}
data:
status:
- completed
response_variable: completed
target:
entity_id: todo.recurring_items_costco
- repeat:
count: "{{ completed['todo.recurring_items_costco']['items'] | count }}"
sequence:
- service: todo.update_item
metadata: {}
data:
status: needs_action
item: >-
{{completed['todo.recurring_items_costco']['items'][repeat.index-1]['summary']}}
target:
entity_id: todo.recurring_items_costco
- conditions:
- condition: trigger
id:
- QFC/Fred Meyer
sequence:
- service: todo.get_items
metadata: {}
data:
status:
- completed
response_variable: completed
target:
entity_id: todo.recurring_items_qfc_fred_meyer
- repeat:
count: >-
{{ completed['todo.recurring_items_qfc_fred_meyer']['items'] |
count }}
sequence:
- service: todo.update_item
metadata: {}
data:
status: needs_action
item: >-
{{completed['todo.recurring_items_qfc_fred_meyer']['items'][repeat.index-1]['summary']}}
target:
entity_id: todo.recurring_items_qfc_fred_meyer
mode: single
Then I created a dashboard that shows the two lists and gives a button at the top to reset the one you’re looking at:
views:
- title: Costco
path: costco
icon: mdi:alpha-c-box-outline
theme: Google Theme
cards:
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.reset_costco_list
icon_height: 50px
theme: Google Theme
- type: todo-list
entity: todo.recurring_items_costco
title: Costco List
theme: Google Theme
- title: QFC/Fred Meyer
path: qfc-fred-meyer
icon: mdi:alpha-q-box-outline
cards:
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.reset_qfc_fred_meyer_list
icon_height: 50px
theme: Google Theme
- type: todo-list
entity: todo.recurring_items_qfc_fred_meyer
title: QFC / Fred Meyer List
theme: Google Theme
theme: Google Theme
Waiting on approval from my partner, but I think this should get a gold star.
Now for a question…
If I were to have an item called “Chicken” on the Costco list, could I add in the description “Recurring” and have the automation go through the list looking for “Recurring” and only reset the status of those items? Basically to account for the onesy-twosy items like spices that don’t need to be reset.
Hello,
is there a way to create an automation if all item from todo list are complete?
You can set an automation to trigger when your todo list item reaches 0.
alias: Example
description: ""
trigger:
- platform: state
entity_id:
- todo.chores
to: "0"
condition: []
action:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.front_lamp
mode: single
Hi, I wanted to do this as well (have a recurring / resetting To-Do list), and making that happen seems needlessly complicated right now. So I thought I’d try to see if I could implement a feature for a “remove all items in To-Do list” service. This would be my first time contributing to home assistant so I’m not promising anything, but I’ve done a first stab at the code changes already. Would a “remove_all_items” service make people in this thread happy? The idea would be to first to “remove_all_items” and then re-populate the list with new items.
If I forgot I ever started this and someone wants to pick up, my WIP code change is here: GitHub - arghle/ha-core at refs/heads/todo-remove-all-items