-
Notifications
You must be signed in to change notification settings - Fork 14
/
events.yaml
74 lines (71 loc) · 2.04 KB
/
events.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
71
72
73
74
- alias: Events - Milestone Notifications
id: event_milestone_notifications
trigger:
- platform: time
at: '10:00:00'
- platform: time
at: '15:30:00'
- platform: time
at: '19:00:00'
variables:
target_date: >
{{ today_at().date() | string }}
events: >
{{ state_attr('binary_sensor.personal_events', 'events') | selectattr('when', 'eq', target_date) | list }}
condition:
- condition: state
entity_id: binary_sensor.personal_events
state: 'on'
action:
- repeat:
for_each: "{{ events }}"
sequence:
- service: script.notify
data:
message: >
Today is {{ repeat.item.who }}s {{ repeat.item.event }}!
- alias: Events - Milestone Reminders
id: event_milestone_reminders
trigger:
- platform: time
at: '10:00:00'
- platform: time
at: '15:30:00'
- platform: time
at: '19:00:00'
variables:
target_dates: >
{% set ns = namespace(dates=[]) %}
{%- for offset in [30, 14, 7] %}
{%- set ns.dates = ns.dates + [(today_at() + timedelta(days=offset)).date() | string] %}
{%- endfor %}
{{ ns.dates }}
events: >
{{ state_attr('binary_sensor.personal_events', 'events') | selectattr('when', 'in', target_dates) | selectattr('who', 'search', 'Mike|Lindsay') | list }}
condition:
- condition: template
value_template: "{{ events | count > 0 }}"
action:
- repeat:
for_each: "{{ events }}"
sequence:
- service: script.notify
data:
message: >
{{ repeat.item.who }}s {{ repeat.item.event }} is in {{ repeat.item.days_away }} day{{ 's' if repeat.item.days_away > 1 else '' }}!
- alias: Events - Calendar Reminders
id: event_calendar_reminders
trigger:
- platform: time
at: '19:00:00'
action:
- service: script.events
- alias: Events - Forward Reload Templates
id: reload_templates
trigger:
- platform: event
event_type: event_template_reloaded
action:
- delay: "00:00:01"
- event: templates_reloaded
event_data: {}