Last active
April 22, 2024 09:40
-
-
Save andrew-codechimp/2d348f9b35ddbea526b88102c972539d to your computer and use it in GitHub Desktop.
Home Assistant - Add unique to-do item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: mylistneedsaction | |
- service: todo.get_items | |
target: | |
entity_id: "{{ list }}" | |
data: | |
status: completed | |
response_variable: mylistcompleted | |
- if: | |
- condition: template | |
value_template: >- | |
{{ | |
mylistcompleted[list]['items']|selectattr('summary','search',item)|list|count | |
== 1 }} | |
then: | |
- service: todo.update_item | |
data: | |
item: "{{ item }}" | |
status: needs_action | |
target: | |
entity_id: "{{ list }}" | |
else: | |
- if: | |
- condition: template | |
value_template: >- | |
{{ | |
mylistneedsaction[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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified so that it will now check if an item is completed and mark it as uncompleted.