Automation based on if specific tasks are open on a To-Do List

Hello!

I want to set up an automation where I get notified if I do not complete certain tasks off my to-do list. I am having a hard time calling the status of a specific item on a to-do list. Getting all of the items with the “needs_action” status is easy, see here
But I want to get only get back specific open to-do list items not the whole list.
I have tried

{{ state(‘todo.before_bed’,‘Litter’,‘status’) }}

but it does not return anything.

Thank you in advance!

Well state doesn’t actually exist as a function.

First you need to use a return response with the get_items call, then you can check if an item exists in that list.

For example, lets say that you use a response variable called todo

{{ todo['todo.before_bed']['items']|selectattr('summary','search','Litter')|list|count > 0 }}

This will evaluate to true, if there is more than 1 item matching a summary of ‘Litter’ on your returned todo items.

Thank you for the quick response!

I am not quite sure how to apply your recommendation.

I generate a list as follows:

service: todo.get_items
target:
entity_id: todo.before_bed
data:
status: needs_action
enabled: true
response_variable: todo

then I check for 'Litter; via your recommendation but it returns false, am I missing something? Litter is on my todo list

You are checking in the same automation?

Here’s an example:

alias: Todo test
description: ""
trigger:
  - platform: time
    at: "21:00:00"
condition: []
action:
  - service: todo.get_items
    target:
      entity_id: todo.andy_s_tasks
    data:
      status: needs_action
    response_variable: todo
  - condition: template
    value_template: >-
      {{
      todo['todo.andy_s_tasks']['items']|selectattr('summary','search','Electric')|list|count
      > 0 }}
  - service: notify.mobile_app_pixel_8_pro
    data:
      message: Electric reading needs to be done!
      title: Reminder!
mode: single

This would tell me if there is an item that contains Electric in the summary of the returned items.

I am still not getting it. I made a helper just to see if i get a result

action:

  • service: todo.get_items
    target:
    entity_id: todo.before_bed
    data:
    status: needs_action
    response_variable: todo
  • condition: template
    value_template: |2-
        {{
        todo['todo.todo.before_bed']['items']|selectattr('summary','search','Litter')|list|count
        > 0 }}
    
  • service: input_boolean.turn_on
    target:
    entity_id: input_boolean.test_toggle
    data: {}
    mode: single

That’s wrong.

todo['todo.before_bed']

That was it! Thank you!

1 Like