Help,
how do I get a list of tasks using the todo.get_tasks
alias: "!Test todo"
description: ""
trigger: []
condition: []
action:
- service: todo.get_items
target:
entity_id: todo.my_tasks
data:
status: needs_action
response_variable: agenda
- service: notify.michael_2
data:
title: Daily agenda for {{ now().date() }}
message: >-
Your agenda for today: <p> </p>
{% for itmes in "agenda.todo.my_tasks" %} {{ itmes }} {{itmes.summary}}
<br> {% endfor %}
mode: single
The output when caling the service in development tools looks like this
todo.my_tasks:
items:
- summary: "Run for cover "
uid: U3ZYX1pMb2FreURETzdNNA
status: needs_action
due: "2023-12-06"
- summary: "Task 22"
uid: YUh4UFFvX1NlNHhfOFJwNA
status: needs_action
four2six
(J.)
December 7, 2023, 11:56am
2
is the spelling error āitmesā instead of āitemsā intentional?
four2six:
items
Sorry to say, it makes no diffrence, just testet itā¦
the {{ agenda }} gives this:
{'todo.my_tasks': {'items': [{'summary': 'Blodtryk ', 'uid': 'U3ZYX1pMb2FreURETzdNNA', 'status': 'needs_action', 'due': '2023-12-06'}, {'summary': 'SƦlge', 'uid': 'YUh4UFFvX1NlNHhfOFJwNA', 'status': 'needs_action'}, {'summary': 'strĆømsvigts monitor', 'uid': 'aUlIZXliUkwtRi1jNGxDcw', 'status': 'needs_action'}, {'summary': 'radar pĆ„ bad', 'uid': 'aElEMldsRWFLWWN2c1JBSQ', 'status': 'needs_action'}, {'summary': 'Kaffemaskine renses', 'uid': 'RG5WbGFHNGdlbkJRcW41dw', 'status': 'needs_action'}, {'summary': 'Fremtidsfuldmagt', 'uid': 'a0JERDFTM1U2ekU5NkZKaw', 'status': 'needs_action'}, {'summary': 'Skriv vp', 'uid': 'NGc1bHZlUkw3TjU3ZXpveA', 'status': 'needs_action'}]}}
jazzyisj
(Jason)
December 7, 2023, 12:23pm
4
- service: todo.get_items
target:
entity_id: todo.hass_ideas
response_variable: mylist
- service: system_log.write
data:
message: >
{%- for item in mylist['todo.hass_ideas']['items'] %}
{{ item.summary }}
{%- endfor %}
5 Likes
Steveuk
December 7, 2023, 12:40pm
6
Thanks for this as well works great for me.
Donāt suppose you know how to make it a persistent notification with a done button that marks the list complete.
I have a few similar notifications with buttons but they are all done through Node red but I want to try them with the automations instead.
jazzyisj
(Jason)
December 7, 2023, 12:54pm
7
No such thing. There are no actions for a persistent notification.
1 Like
I wrote that wrong I meant a actionable notification that is persistent.
I think Iāve figured it out now Iāve got the notification to be persistent Iām going to set up the action part later when Iām on my laptop.
Thanks
NullJackal
(ā
-Jackal)
December 29, 2023, 11:52am
9
Just piping in here because this took me a while to figure out (Iām pretty low-level) and this thread helped me a lot. (Thank you @jazzyisj ! )
Specifically, to reference specific items in the list I went with
variables:
Output: "{{ TList['todo.test_list']['items'][-1]['summary'] }}"
Where āTlistā is the output of the todo.get_tasks call. Grabs the last (newest) item in the list. For checked or unchecked this is the last thing to be changed. Using this in an automation that updates the house group in Teams whenever someone changes the chore and shopping lists. To get the oldest item in the list swap out [-1] for [0]
1 Like
PX80
January 2, 2024, 12:50pm
10
Is there a way to get the output into a Dashboard Card? I am replacing Google Keep and i want to permanently list the ToDo Action in the Dhasboard.
jazzyisj
(Jason)
January 2, 2024, 9:29pm
11
I think the docs need to be updated, I donāt see the Todo card listed, but it is a thing.
Try this or you can configure the ToDo card in the dashboard edit UI.
type: todo-list
title: Jason Tasks
entity: todo.jasons_tasks
1 Like
PX80
January 3, 2024, 9:07am
12
thanks thats exactly what i was looking for
DivanX10
(Divan X10)
January 15, 2024, 10:49pm
13
I didnāt find any examples, Iāll add them as an addition to your code. There will be another option
If you use the code that you specified, then the list will go in one line in the message
{%- for item in mylist['todo.hass_ideas']['items'] %}
{{ item.summary }}
{%- endfor %}
I wanted the list in the message to be not in one line, but in a column.
message: >
{% set shop_list = shopping_list['todo.shopping_list']['items'] %}
{%- for item in shop_list -%}
- {{ item.summary ~ "\n" }}
{%- endfor -%}
1 Like
lhanneus
(Luc Hanneuse)
February 7, 2024, 7:38pm
14
Probably a newbie question : How to get only the 1st element/item in the todo list ?
jazzyisj
(Jason)
February 12, 2024, 1:03am
15
How to get only the 1st element/item in the todo list ?
test:
sequence:
- service: todo.get_items
target:
entity_id: todo.hass_ideas
response_variable: mylist
- service: persistent_notification.create
data:
title: "First Item"
message: >
{% if mylist['todo.hass_ideas']['items'][0] is defined %}
{{ mylist['todo.hass_ideas']['items'][0]['summary'] }}
{% endif %}
continue_on_error: true
1 Like
Thank you all for the inputs! But Iām having some problems, when i run it it only sends a message āagenda.toā with each letter on an own row:
alias: "Test: todo"
description: ""
trigger: []
condition: []
action:
- service: todo.get_items
target:
entity_id: todo.kvantum_apotek
response_variable: mylist
- service: system_log.write
data:
message: >
{% set shop_list = shopping_list['todo.kvantum_apotek']['items'] %}
{%- for item in shop_list -%}
- {{ item.summary ~ "\n" }}
{%- endfor -%}
- service: notify.mobile_app_samsung_s22
data:
title: Daily agenda for {{ now().date() }}
message: >-
Your agenda for today: <p> </p>
{% for itmes in "agenda.todo.kvantum_apotek" %} {{ items }}
{{itmes.summary}} <br> {% endfor %}
mode: single
What have i done wrong?!
Thank you in advance
Keellan:
What have i done wrong?!
You used the non working example above.
It should be something like
message: >
Your agenda for today:
{%- for item in mylist['todo.kvantum_apotek']['items'] %}
{{ item.summary }}
{%- endfor %}
if todo.kvantum_apotek is really your entity.
1 Like
Thank you for the reply!
Sorry, forgot to write that I have tried Jasons and DivanX10s solution and i get the same outcome. Mistakenly pasted an old copy
alias: "Test: todo"
description: ""
trigger: []
condition: []
action:
- service: todo.get_items
target:
entity_id: todo.kvantum_apotek
response_variable: mylist
- service: system_log.write
data:
message: >
{% set shop_list = shopping_list['todo.kvantum_apotek']['items'] %}
{%- for item in shop_list -%}
- {{ item.summary ~ "\n" }}
{%- endfor -%}
mode: single
Yes it is
not sure why you try to create new array (shop_list).
sure this doesnāt work?
alias: "Test: todo"
description: ""
trigger: []
condition: []
action:
- service: todo.get_items
target:
entity_id: todo.kvantum_apotek
response_variable: mylist
- service: system_log.write
data:
message: >
{%- for item in mylist['todo.kvantum_apotek']['items'] -%}
- {{ item.summary ~ "\n" }}
{%- endfor -%}
mode: single
1 Like
When i wrote my post i had been awake for 23h I thought i understood a little, but now with a clear head I think I understand nothing
Iām trying to get the same outcome as the thread maker, get a message with the items in one of my lists. Does system_log.write
send the list? How does it know where to send it
Sorry, Iām still a beginner and unlucky in thinking