How to check if item is in ToDo

I am struggling to see if a certain item is in a todo list. I have created a todo for all of my house chores called todo.chores. I am able to call todo.get_items and get back the items from the list

service: todo.get_items
target:
  entity_id: todo.chores
data:
  status: needs_action
response_variable: mylist

The response I get back is

todo.chores:
  items:
    - summary: Water Plants
      uid: 76f128de-9533-11ee-8bde-002324bdfaac
      status: needs_action
    - summary: Feed Cats
      uid: 78745014-9533-11ee-8bde-002324bdfaac
      status: needs_action
    - summary: Dishwasher
      uid: 7b33d806-9533-11ee-8bde-002324bdfaac
      status: needs_action
    - summary: Laundry
      uid: 7e0623a4-9533-11ee-8bde-002324bdfaac
      status: needs_action

From there I am stuck on how to check if an item is in the list.
For context: I want to create an automation that checks if ‘Dishwasher’ is in todo.chores and perform actions if it’s in the todo.

Thank you in advance for the help!

1 Like
- service: todo.get_items
  target:
    entity_id: todo.chores
  data:
    status: needs_action
  response_variable: mylist
- condition: template
  value_template: |
      {{'Dishwasher' in mylist['todo.chores']['items'] | map(attribute='summary') | list}}
- service: ACTION_TO_WASH_THE_DISHES
11 Likes

That worked! Thank you so much!

1 Like

Any idea how to do this same exact thing in Node Red?

I should be clear that the action to check a list would trigger upon the happening of event and then grab the item that appears in the to do list list and then mark the item as complete.

For example: if I have a chore that says take the trash out, the item will be marked as complete when I take the trash out without the need for me to go back in and manually check the item off the list.

I have a similar but different problem:
I would like to show a tile card on my desktop only if one specific todo item is available. Is that feasible?

You would need to create a trigger-based template binary sensor.

template:
  - trigger:
      - platform: time_pattern
        hours: "/1"
      - platform: state
        entity_id: todo.chore
        not_to:
          - unavailable
          - unknown
    action:
      - service: todo.get_items
        target:
          entity_id: todo.chore
        data:
          status: needs_action
        response_variable: mylist
    binary_sensor:
      - name: Diswasher chore active
        state: "{{'Dishwasher' in mylist['todo.chore']['items'] | map(attribute='summary') | list }}"
1 Like