Triggers for Todo entities

I love the new todo entities, though at the moment there doesn’t seem to be a way to trigger automations from the add or delete of new items. It would be possible to trigger an automation based on the number of unchecked items in the state, but this contains no data about the event which was added or removed. Ideally what I’d love to be able to do is something like:

  1. New event is added to my todo list (eg. via Todoist)
  2. A HomeAssistant automation fires off
  3. If the new todo list item contains a certain key word, eg. “remember”, in “remember to mow the lawn”, the automation could take an action such as adding a calendar entry for me on the weekend, or sending me a reminder to my phone at a later time, etc.

I’d also love to be able to use this to “sync” my todo lists between Google Tasks and Todoist; I use Todoist for managing all my tasks, but it has no native Google Home integration. I would love to be able to say to the Google Homes around my house “add ‘mow the lawn’ to my todo list” and have it add that to Google Tasks (as it already does), and then a Home Assistant automation is triggered which takes that task and adds it to my todoist Todo list.

Alternatively, if there was a way to query the contents of a todo list, such as via a service with return data (like the calendar.list_events service) then this could potentially achieve the same outcome by have the automation triggered by todo list state changes, and then lookup the latest list items via the service.

4 Likes

Indeed, the equivalent to “Calendar.list_events” for todo-items would be great. The old shopping list included all items as attributes in the entity and I had automations that then listed all items in an email. This unfortunately doesn’t work anymore since neither are the items attributes in the entity, nor is there a service to call the items :frowning:

Really hope a solution will come around!

See Calendars & Todo-List, upvote it. What you have posted here I believe is encompassed by that request

I agree. And There should be trigger for todo list due_date or due_datetime.

HA is able to react to add/delete of Local to do items in a automation, if the trigger is the state of the todo entity you want watch. I am not sure about the todoist integration provided lists, as I do not use that. Here is a quick example automation to trigger on change of state (number of “needs_attention” items) for a local to do list:

alias: Test to do list state change
description: ""
trigger:
  - platform: state
    entity_id:
      - todo.maintenance
condition: []
action:
  - service: notify.persistent_notification
    metadata: {}
    data:
      message: Test react to do add
      title: Test complete?
mode: single

But I have not found a way to trigger an automation on a to do list item becoming due, without doing some really ugly template and variable storage gymnastics.

So, to my mind, the most elegant solution would be to:

  • Increase the granularity of the “status” attribute for to do list items to more clearly separate those that are due in the future vs already overdue
  • Allow to get the number of future due, overdue, and completed items in the attribute returns from state machine of the to do list entity
  • Possibly a “last overdue” and/or “next due” attribute for the to do list entity might also be useful
  • Therefore, automations could react to an change in the number of items of a particular status
  • It would still take querying entity history to see if the number of items is increasing or decreasing, and to for example only continue if the number of items is increasing. I ended up having to go to node-red to be able to accomplish this for myself, and that is far from an elegant solution.