-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmcu-gate.yaml
284 lines (272 loc) · 7.02 KB
/
mcu-gate.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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
substitutions:
device: gate
name: Gate
comment: "Outside: Gate"
esphome:
name: mcu-${device}
comment: ${comment}
esp32:
board: m5stack-atom
framework:
type: esp-idf
# version: 5.1.2
# platform_version: 6.5.0
external_components:
- source: components
packages:
common: !include common/common.yaml
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26 white
# I2C0 SCL G32
# I2C1 SDA G25 red
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# RS485 RX G33
# RS485 TX G23
# RELAY-1 G22
# RELAY-2 G19
button:
- platform: output
name: "${name} Open"
id: gate_open
output: relay_1
duration: 200ms
- platform: output
name: "${name} Close"
id: gate_close
output: relay_2
duration: 200ms
output:
- platform: gpio
pin: 22
id: relay_1
- platform: gpio
pin: 19
id: relay_2
switch:
- platform: template
name: "${name} Open"
turn_on_action:
- button.press: gate_open
- platform: template
name: "${name} Close"
turn_on_action:
- button.press: gate_close
- platform: template
name: "${name} Auto Open"
id: auto_open
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
- platform: template
name: "${name} Auto Close"
id: auto_close
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
- platform: template
name: "${name} Enable Auris"
id: enable_auris
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
- platform: template
name: "${name} Enable Yaris"
id: enable_yaris
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
- platform: template
name: "${name} Enable Honda PCX125"
id: enable_pcx125
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
- platform: template
name: "${name} Enable Suzuki DL650"
id: enable_dl650
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
# Bluetooth related stuff
esp32_ble_tracker:
id: ${name}_ble_tracker
scan_parameters:
duration: 1min
# bluetooth_proxy:
binary_sensor:
- platform: ble_presence
id: ibeacon_auris
ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid
name: "Vehicle iBeacon Auris"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence
id: ibeacon_yaris
ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid
name: "Vehicle iBeacon Yaris"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence
id: ibeacon_pcx125
ibeacon_uuid: !secret ble_beacon_honda_uuid
name: "Vehicle iBeacon Honda PCX125"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
- platform: ble_presence
id: ibeacon_dl650
ibeacon_uuid: !secret ble_beacon_suzuki_uuid
name: "Vehicle iBeacon Suzuki DL650"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_close
# - platform: gpio
# id: gate_flash
# pin:
# number: 26
# inverted: true
# mode:
# input: true
# filters:
# - delayed_on: 10ms
- platform: gpio
id: gate_ogi
pin:
number: 32
inverted: true
mode:
input: true
filters:
- delayed_on: 10ms
entity_category: diagnostic
on_multi_click:
- timing:
- OFF for at least 1500ms
then:
- select.set:
id: gate_state
option: Closed
- logger.log: "OGI OFF => GATE CLOSED"
invalid_cooldown: 100ms
- timing:
- ON for at least 400ms
- OFF for at least 400ms
- ON for at least 400ms
- OFF for at least 400ms
then:
- select.set:
id: gate_state
option: Opening
- logger.log: "OGI SLOW BLINK => GATE OPENING"
invalid_cooldown: 100ms
- timing:
- ON for at most 300ms
- OFF for at most 300ms
- ON for at most 300ms
- OFF for at most 300ms
then:
- select.set:
id: gate_state
option: Closing
- logger.log: "OGI FAST BLINK => GATE CLOSING"
invalid_cooldown: 100ms
- timing:
- ON for at least 1500ms
then:
- select.set:
id: gate_state
option: Open
- logger.log: "OGI ON => GATE OPEN"
invalid_cooldown: 100ms
select:
- platform: template
name: Gate
id: gate_state
options:
- Open
- Closed
- Opening
- Closing
initial_option: Closed
optimistic: true