blob: 03f4ff3c12e989af808aa2d86b98e873a9a6df65 (
plain)
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
blueprint:
name: Halabyan24 Global Motions
description: Global motion/tracking rules for Halabyan 24
domain: automation
trigger:
# We get home (we rather rely on motion sensor here)
# - platform: state
# id: home
# entity_id:
# - group.master_phones
# from: not_home
# to: home
# for:
# hours: 0
# minutes: 1
# seconds: 0
# We get away from home (even near-by)
- platform: state
id: not_home
entity_id:
- group.master_phones
from: home
to: not_home
for:
hours: 1
minutes: 0
seconds: 0
# We get in home area (from outside)
- platform: state
id: around_home
entity_id:
- device_tracker.lm_g810
from: not_home
to: HomeHalabyanExtended
for:
hours: 0
minutes: 4
seconds: 0
- platform: state
id: around_home2
entity_id:
- device_tracker.lm_g810
from: not_home
to: home
for:
hours: 0
minutes: 2
seconds: 0
# We get away from home area (or directly from home)
- platform: state
id: away_from_home
entity_id:
- device_tracker.lm_g810
from: HomeHalabyanExtended
to: not_home
for:
hours: 1
minutes: 0
seconds: 0
- platform: state
id: away_from_home2
entity_id:
- device_tracker.lm_g810
from: home
to: not_home
for:
hours: 1
minutes: 0
seconds: 0
# No motions in the hall for a day
- platform: state
entity_id: binary_sensor.hall_motions_occupancy
from: "on"
to: "off"
for:
hours: 24
minutes: 0
seconds: 0
id: empty_day
# No motions in the hall for a week
- platform: state
entity_id: binary_sensor.hall_motions_occupancy
from: "on"
to: "off"
for:
hours: 120
minutes: 0
seconds: 0
id: empty_week
# Motions in the hall detected
- platform: state
entity_id: binary_sensor.hall_motions_occupancy
from: "off"
to: "on"
for:
hours: 0
minutes: 1
seconds: 0
id: motions
# 'Away' security mode is turned off
- platform: state
entity_id:
- input_boolean.mode_away
from: 'on'
to: 'off'
id: away_gone
condition: []
action:
- choose:
# Set 'away' security mode if no motions for 1 day (or for 2 hours if we are 'alone' and left 'home area')
- conditions:
- condition: state
entity_id: input_boolean.mode_away
state: 'off'
- condition: or
conditions:
- condition: trigger
id: empty_day
- condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: away_from_home
- condition: trigger
id: away_from_home2
- condition: state
entity_id: input_boolean.mode_house_sleep
state: 'on'
sequence:
- service: switch.turn_on
target:
entity_id: switch.hall_lights_right
# Set house to 'sleep' if no motions for 1 day (or for 2 hours if we are 'alone' and left 'home')
- conditions:
- condition: state
entity_id: input_boolean.mode_house_sleep
state: 'off'
- condition: or
conditions:
- condition: trigger
id: empty_day
- condition: and
conditions:
- condition: trigger
id: not_home
# - condition: state
# entity_id: input_boolean.mode_alone
# state: 'on'
- condition: state
entity_id: input_boolean.mode_guests
state: 'off'
- condition: state
entity_id: binary_sensor.hall_motions_occupancy
state: 'off'
for:
hours: 2
minutes: 0
seconds: 0
sequence:
- service: script.sleep_and_wake
data:
mode: sleep
target: house
# Set house to 'hibernate' if no motions for a week
- conditions:
- condition: trigger
id: empty_week
- condition: state
entity_id: input_boolean.mode_house_hibernate
state: 'off'
sequence:
- service: script.sleep_and_wake
data:
mode: hibernate
target: house
# Disable 'away' security mode if our phone is in vicinity
- conditions:
- condition: or
conditions:
- condition: trigger
id: around_home
- condition: trigger
id: around_home2
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.hall_lights_right
# 'Wake' house if it was 'sleeping'/'hibernated' and
# * either there are motions in hall and 'away' security mode is not set
# * or 'away' security mode is just turned off
- conditions:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.mode_house_sleep
state: 'on'
for:
hours: 0
minutes: 10
seconds: 0
- condition: state
entity_id: input_boolean.mode_house_hibernate
state: 'on'
for:
hours: 0
minutes: 10
seconds: 0
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id: motions
- condition: state
entity_id: input_boolean.mode_away
state: 'off'
- condition: and
conditions:
- condition: trigger
id: away_gone
- type: is_motion
condition: device
device_id: 6deb0a6fb7a4a849ba22afc166cf9919
entity_id: binary_sensor.hall_motions_occupancy
domain: binary_sensor
sequence:
- if:
- condition: state
entity_id: input_boolean.mode_house_hibernate
state: 'on'
then:
- service: script.sleep_and_wake
data:
mode: wake
target: house
- service: input_boolean.turn_off
data: {}
target:
entity_id:
- input_boolean.mode_house_sleep
- input_boolean.mode_house_hibernate
default: []
mode: single
|