teadragon7
(Teadragon7)
December 17, 2023, 5:21pm
1
Hello!
I want to set up an automation where I get notified if I do not complete certain tasks off my to-do list. I am having a hard time calling the status of a specific item on a to-do list. Getting all of the items with the “needs_action” status is easy, see here
But I want to get only get back specific open to-do list items not the whole list.
I have tried
{{ state(‘todo.before_bed’,‘Litter’,‘status’) }}
but it does not return anything.
Thank you in advance!
Well state doesn’t actually exist as a function.
First you need to use a return response with the get_items call, then you can check if an item exists in that list.
For example, lets say that you use a response variable called todo
{{ todo['todo.before_bed']['items']|selectattr('summary','search','Litter')|list|count > 0 }}
This will evaluate to true, if there is more than 1 item matching a summary of ‘Litter’ on your returned todo items.
teadragon7
(Teadragon7)
December 17, 2023, 6:17pm
3
Thank you for the quick response!
I am not quite sure how to apply your recommendation.
I generate a list as follows:
service: todo.get_items
target:
entity_id: todo.before_bed
data:
status: needs_action
enabled: true
response_variable: todo
then I check for 'Litter; via your recommendation but it returns false, am I missing something? Litter is on my todo list
You are checking in the same automation?
Here’s an example:
alias: Todo test
description: ""
trigger:
- platform: time
at: "21:00:00"
condition: []
action:
- service: todo.get_items
target:
entity_id: todo.andy_s_tasks
data:
status: needs_action
response_variable: todo
- condition: template
value_template: >-
{{
todo['todo.andy_s_tasks']['items']|selectattr('summary','search','Electric')|list|count
> 0 }}
- service: notify.mobile_app_pixel_8_pro
data:
message: Electric reading needs to be done!
title: Reminder!
mode: single
This would tell me if there is an item that contains Electric
in the summary of the returned items.
teadragon7
(Teadragon7)
December 17, 2023, 6:36pm
5
I am still not getting it. I made a helper just to see if i get a result
action: