-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwaste.yaml
211 lines (198 loc) · 7.14 KB
/
waste.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
################################################
## Packages
################################################
homeassistant:
customize:
sensor.afvalwijzer_today:
friendly_name: Vandaag
sensor.afvalwijzer_tomorrow:
friendly_name: Morgen
sensor.afvalwijzer_next_item:
friendly_name: Next pickup item
sensor.afvalwijzer_next_in_days:
friendly_name: Next pickup in days
input_boolean.waste_reminder:
icon: mdi:reminder
sensor.afvalwijzer_gft:
friendly_name: GFT
entity_picture: /local/afvalwijzer/GFT.png
sensor.afvalwijzer_papier:
friendly_name: Papier
entity_picture: /local/afvalwijzer/Papier.png
sensor.afvalwijzer_pmd:
friendly_name: PMD
entity_picture: /local/afvalwijzer/PMD.png
sensor.afvalwijzer_restafval:
friendly_name: Restafval
entity_picture: /local/afvalwijzer/Restafval.png
################################################
## Inputs
################################################
input_boolean:
waste_moved:
name: Waste has been moved
initial: "off"
icon: mdi:delete-empty
waste_reminder:
name: Waste reminder enabled
initial: "on"
icon: mdi:delete-empty
trash_outside:
name: Trash outside reminder
initial: "off"
icon: mdi:delete-empty
################################################
## Sensor
################################################
sensor:
# api_token: 5ef443e778f41c4f75c69459eea6e6ae0c2d92de729aa0fc61653815fbd6a8ca
- platform: afvalwijzer
provider: mijnafvalwijzer
postal_code: !secret afvalwijzer_postcode
street_number: !secret afvalwijzer_huisnummer
- platform: template
sensors:
afvalwijzer_next_item_formatted:
value_template: >-
{% if is_state('sensor.afvalwijzer_next_item', 'gft') %}GFT
{% elif is_state('sensor.afvalwijzer_next_item', 'papier') %}Papier
{% elif is_state('sensor.afvalwijzer_next_item', 'pmd') %}PMD
{% elif is_state('sensor.afvalwijzer_next_item', 'restafval') %}Restafval
{% else %}Geen
{% endif %}
friendly_name: "Next pickup item"
afvalwijzer_today_formatted:
value_template: >-
{% if is_state('sensor.afvalwijzer_today', 'gft') %}GFT
{% elif is_state('sensor.afvalwijzer_today', 'papier') %}Papier
{% elif is_state('sensor.afvalwijzer_today', 'pmd') %}PMD
{% elif is_state('sensor.afvalwijzer_today', 'restafval') %}Restafval
{% else %}Geen
{% endif %}
friendly_name: "Vandaag"
afvalwijzer_tomorrow_formatted:
value_template: >-
{% if is_state('sensor.afvalwijzer_tomorrow', 'gft') %}GFT
{% elif is_state('sensor.afvalwijzer_tomorrow', 'papier') %}Papier
{% elif is_state('sensor.afvalwijzer_tomorrow', 'pmd') %}PMD
{% elif is_state('sensor.afvalwijzer_tomorrow', 'restafval') %}Restafval
{% else %}Geen
{% endif %}
friendly_name: "Morgen"
afvalwijzer_day_after_tomorrow_formatted:
value_template: >-
{% if is_state('sensor.afvalwijzer_day_after_tomorrow', 'gft') %}GFT
{% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'papier') %}Papier
{% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'pmd') %}PMD
{% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'restafval') %}Restafval
{% else %}Geen
{% endif %}
friendly_name: "Overmorgen"
################################################
## Automation
################################################
automation:
- alias: Afval - Herstel notificatie
trigger:
platform: state
entity_id: input_boolean.waste_moved
to: "on"
for:
hours: 12
action:
- service: input_boolean.turn_off
entity_id: input_boolean.waste_moved
- service: input_boolean.turn_on
entity_id: input_boolean.waste_reminder
- alias: Afval - Bevestig notificatie
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "MARK_WASTE_MOVED"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.waste_moved
- service: input_boolean.turn_on
entity_id: input_boolean.trash_outside
- service: notify.family
data:
title: "Afval"
message: "Afvaltype(n): {{ states.sensor.afvalwijzer_tomorrow_formatted.state }} zijn aan de straat gezet."
data:
push:
badge: 0
- alias: Afval - Verzend notificatie - Tomorrow
trigger:
platform: time_pattern
hours: "/1"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.waste_moved
state: "off"
- condition: state
entity_id: input_boolean.waste_reminder
state: "on"
- condition: time
after: "18:00:00"
before: "23:00:00"
- condition: template
value_template: "{{ states('sensor.afvalwijzer_tomorrow_formatted') != 'Geen' }}"
action:
- service: notify.family
data:
title: "Afval"
message: 'Het is vandaag - {{ now().strftime("%d-%m-%Y") }}. Afvaltype(n): {{ states.sensor.afvalwijzer_tomorrow_formatted.state }} wordt opgehaald op: {{ (as_timestamp(now()) + (24*3600)) | timestamp_custom("%d-%m-%Y", True) }}!'
data:
actions:
- action: "MARK_WASTE_MOVED"
title: "Afval verwerkt"
activationMode: "background"
authenticationRequired: no
destructive: yes
behavior: "default"
push:
badge: 5
action_data:
entity_id: input_boolean.trash_outside
# TEST ACTION
#- service: notify.bram
# data:
# title: iOS notification
# message: >
# {{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald, zet het afval aan de straat
# data:
# actions:
# - action: MARK_TRASH_MOVED
# title: Afval verwerkt
# authenticationRequired: false
# activationMode: background
# destructive: true
# push:
# badge: 5
# action_data:
# entity_id: input_boolean.trash_outside
# # TEST
# - alias: Mark trash as moved outside from notification
# id: Mark trash as moved outside from notification
# trigger:
# platform: event
# event_type: mobile_app_notification_action
# event_data:
# action: MARK_TRASH_MOVED
# action:
# - service: input_boolean.turn_on
# entity_id: input_boolean.trash_outside
# - service: persistent_notification.dismiss
# data:
# notification_id: >
# trash-notification-{{'today' if is_state('persistent_notification.trash_notification_today','notifying') else 'tomorrow'}}
# - service: notify.bram
# data:
# title: iOS notification
# message: Afval staat aan de straat
# data:
# push:
# badge: 0