-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo_overdue_notifications.yaml
70 lines (66 loc) · 1.81 KB
/
todo_overdue_notifications.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
blueprint:
name: ToDo overdue reminders
description: Sends notifications with items that are overdue
author: Dany Khalife
domain: automation
input:
lists:
description: The ToDo lists to scan
selector:
entity:
domain: todo
multiple: true
notification_time:
description: The time at which the notification is sent
selector:
time:
default:
hours: 8
minutes: 0
seconds: 0
notify:
description: The notification service to use for notifications.
selector:
device:
integration: mobile_app
mode: single
trigger:
- platform: time
at: !input notification_time
condition: []
action:
- metadata: {}
data:
status: needs_action
target:
entity_id: !input lists
response_variable: tasks
action: todo.get_items
- variables:
tasks_overdue: >
{%- set today = now().strftime('%Y-%m-%d')-%}
{%- set ns = namespace(result = []) -%}
{%- for listName in tasks -%}
{% set tasks_list = tasks[listName]['items'] %}
{%- if tasks_list is iterable -%}
{%- for task in tasks_list -%}
{%- if 'due' in task -%}
{%- if task['due'].split('T')[0] < today -%}
{%- set ns.result = ns.result + [task['summary']] -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- if ns.result is iterable -%}
{%- for item in ns.result %}
- {{ item }}
{%- endfor -%}
{%- endif -%}
- condition: template
value_template: "{{ tasks_overdue != '' }}"
- device_id: !input notify
domain: mobile_app
type: notify
title: Overdue tasks
message: "{{ tasks_overdue }}"