-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathautomations.yaml
204 lines (192 loc) · 6.01 KB
/
automations.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
# https://www.home-assistant.io/docs/automation/trigger/
# https://www.home-assistant.io/docs/automation/condition/
# https://www.home-assistant.io/docs/automation/action/
# 这个文件记录的是自动化的相关内容。
# 可以在达到某个条件时,触发一系列的操作。
# 回家时
# 这里用的一个临时方案。我tracking的方式有两种,iCloud和ping。
# iCloud只能判断设备的大致范围,而ping在手机休眠时有可能离线。
# 所以单独用任何一种都无法获得准确的到家时间。
# 现在先通过iCloud判断是否到了家附近,是的话打开一个标记home_return_fuzzy。
# 然后通过ping来触发精确的到家时间点。
# (ping默认间隔12秒,所以到家进门连上设备+被ping到,还是会有一点延迟。)
# 旧方案是只用iCloud,那就会有点提前。
# 开启即将到家的状态
# - id: home_return_fuzzy # 这个id没啥卵用 unique就行
# alias: Home Return Fuzzy # 这个名称会以下划线替换空格成为id
# description: 判断即将到家
# trigger:
# - entity_id: device_tracker.erimuss_iphonexr
# platform: state
# from: 'not_home'
# to: 'home'
# action:
# - service: input_boolean.turn_on # 状态记录器
# entity_id: input_boolean.home_return_fuzzy
# # 精确的到家时间 ping作为开关
# - id: home_return_exact
# alias: Home Return Exact # 这个名称会以下划线替换空格成为id
# description: 回家时开启电器
# trigger:
# - entity_id: device_tracker.pingiphonexr
# platform: state
# from: 'not_home'
# to: 'home'
# condition:
# condition: state
# entity_id: input_boolean.home_return_fuzzy
# state: 'on'
# action:
# - service: script.home_return_exact
# # 离家时
# - id: home_leave
# alias: Home Leave
# description: 离家时关闭电器
# trigger:
# - entity_id: device_tracker.erimuss_iphonexr
# platform: state
# from: 'home'
# to: 'not_home'
# # platform: zone
# # zone: zone.home
# # event: leave
# condition: # 防止iCloud偶尔抽风误触 加一个ping判断
# - condition: state
# entity_id: device_tracker.pingiphonexr
# state: 'not_home'
# action:
# - service: switch.turn_off
# entity_id:
# - switch.amplifier_smart
# - switch.water_pump
# - switch.aircon_power_off
# - group.light
# - service: input_boolean.turn_off # 状态记录器
# entity_id: input_boolean.home_return_fuzzy
# 监听水泵开启,在15分钟后自动发送一次关闭命令。防止忘记关水泵。
- id: auto_turn_off_pump
alias: Auto turn off pump
description: 自动关水泵
trigger:
- entity_id: switch.water_pump
platform: state
from: 'off'
to: 'on'
for: 00:15:00
condition: []
action:
- entity_id: switch.water_pump
service: switch.turn_off
# 每整点关一次水泵 避免漏关
- id: auto_turn_off_pump_hourly
alias: Auto turn off pump hourly
trigger:
platform: time_pattern
minutes: 0
condition: []
action:
- entity_id: switch.water_pump
service: switch.turn_off
# 监听空气污染状态
# - id: auto_turn_on_purifier
# alias: Auto turn on purifier
# description: 根据空气状态自动开净化器
# trigger:
# platform: time_pattern
# minutes: '/10'
# condition:
# condition: and
# conditions:
# - condition: state
# entity_id: input_boolean.at_home
# state: 'on'
# - condition: numeric_state
# entity_id: sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan
# above: 75
# - condition: state
# entity_id: switch.purifier
# state: 'off'
# action:
# - entity_id: switch.purifier
# service: switch.turn_on
# - entity_id: switch.purifier
# service: switch.turn_on
# - entity_id: switch.purifier
# service: switch.turn_on
# - id: auto_turn_off_purifier
# alias: Auto turn off purifier
# description: 根据空气状态自动关净化器
# trigger:
# platform: time_pattern
# minutes: '/10'
# condition:
# condition: and
# conditions:
# - condition: state
# entity_id: input_boolean.at_home
# state: 'on'
# - condition: numeric_state
# entity_id: sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan
# below: 75
# - condition: state
# entity_id: switch.purifier
# state: 'on'
# action:
# - entity_id: switch.purifier
# service: switch.turn_off
# - entity_id: switch.purifier
# service: switch.turn_off
# - entity_id: switch.purifier
# service: switch.turn_off
# 每整点关一次水泵 避免漏关
- id: auto_turn_off_pump_hourly
alias: Auto turn off pump hourly
trigger:
platform: time_pattern
minutes: 0
condition: []
action:
- entity_id: switch.water_pump
service: switch.turn_off
# ===== test below
# 精确的到家时间 person.erimus 作为开关
- id: erimus_return
alias: Erimus Return # 这个名称会以下划线替换空格成为id
description: 回家时开启电器
trigger:
- entity_id: person.erimus
platform: state
from: 'not_home'
to: 'home'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'off'
# avoid tirggering by mistake while sleeping
- condition: time
after: '08:00:00'
before: '22:00:00'
action:
- service: script.home_return
# 离家时
- id: erimus_leave
alias: Erimus Leave
description: 离家时关闭电器
trigger:
- entity_id: person.erimus
platform: state
from: 'home'
to: 'not_home'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- condition: state
entity_id: input_boolean.playing_sound
state: 'off'
# avoid tirggering by mistake while sleeping
- condition: time
after: '08:00:00'
before: '22:00:00'
action:
- service: script.home_leave