Open to-do list as a notification with action buttons

After today’s release of Home Assistant I wrote up this little notification. It shows you how much unchecked boxes there are in a given grocery list in the notification and a handy link to a lovelace dashboard containing the grocery list as a full panel view.

service: notify.mobile_app_nothing_phone_1
data:
  message: >-
    There {% if states('todo.boodschappenlijstje') | int < 2 %} is{%else%}
    are{%endif%} {{ states('todo.boodschappenlijstje')}} {% if
    states('todo.boodschappenlijstje') | int < 2 %} product{%else%}
    producten{%endif%} left on the grocery list.
  title: Brian is at the supermarket
  data:
    actions:
      - action: URI
        title: Open grocery list
        uri: /lovelace-home/grocerylist

Combine this with a zone automation (eg. entering the local supermarket) and send this notification to your partner.

9 Likes

I am very new to templates and coding in Yaml how would you go about adding a condition so the notification isn’t sent when the list has 0 open items?

I am also new to this, but I think the answer to your question is to check the number of items in the list as a condition when triggering the automation. Each automation has:

  • Trigger
  • Conditions (optional)
  • Actions

The YAML above just shows the Action part which is to call the notify service.

The entire automation might look like:

alias: Zone Based Automation
description: ""
trigger:
  - platform: geo_location
    source: person
    zone: zone.market
    event: enter
condition:
  - condition: numeric_state
    entity_id: todo.shoppinglist
    above: 0
action:
  - service: notify.mobile_app_nothing_phone_1
    data:
      message: >-
        There {% if states('todo.shoppinglist') | int < 2 %} is{%else%}
        are{%endif%} {{ states('todo.shoppinglist')}} {% if
        states('todo.shoppinglist) | int < 2 %} product{%else%}
        products{%endif%} left on the grocery list.
      title: At the supermarket
      data:
        actions:
          - action: URI
            title: Open grocery list
            uri: /lovelace-home/shoppinglist
mode: single

With the above YAML the condition will prevent the message from being sent if the shopping list is zero length. NOTE: I have never used the geo_location trigger, so that part of the YAML may need changes.

That is not how the Geolocation trigger works… you want a Zone trigger.