Skip to content

Instantly share code, notes, and snippets.

@davosian
Forked from andrew-codechimp/add_unique_todo.yaml
Created March 21, 2024 21:54
Show Gist options
  • Save davosian/de4ec1a1299fa3348b08af4cd1e75d28 to your computer and use it in GitHub Desktop.
Save davosian/de4ec1a1299fa3348b08af4cd1e75d28 to your computer and use it in GitHub Desktop.

Revisions

  1. @andrew-codechimp andrew-codechimp created this gist Mar 9, 2024.
    38 changes: 38 additions & 0 deletions add_unique_todo.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    alias: Add unique to-do
    mode: single
    icon: mdi:clipboard-list
    sequence:
    - service: todo.get_items
    target:
    entity_id: "{{ list }}"
    data:
    status: needs_action
    response_variable: mylist
    - if:
    - condition: template
    value_template: >-
    {{
    mylist[list]['items']|selectattr('summary','search',item)|list|count
    == 0 }}
    then:
    - service: todo.add_item
    metadata: {}
    data:
    item: "{{ item }}"
    target:
    entity_id: "{{ list }}"
    fields:
    item:
    selector:
    text: null
    name: Item
    description: The to-do item to add
    required: true
    list:
    selector:
    entity:
    filter:
    - domain: todo
    name: List
    required: true
    description: The to-do list