-
Notifications
You must be signed in to change notification settings - Fork 2
/
home_door.yaml
241 lines (223 loc) · 5.8 KB
/
home_door.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
esphome:
name: home_door
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pswd
ap:
ssid: "Home Door Fallback Hotspot"
password: !secret wifi_pswd
captive_portal:
web_server:
port: 80
# Enable logging
logger:
level: INFO
ota:
globals:
- id: steps_full
type: int
initial_value: '3200'
- id: steps_open_latch
type: int
initial_value: '-1288'
- id: steps_offset_latch
type: int
initial_value: '-200'
- id: beeps
type: int
uart:
rx_pin: D5
tx_pin: D6
baud_rate: 57600
fingerprint_grow:
sensing_pin: D7
on_finger_scan_matched:
- homeassistant.event:
event: esphome.test_fingerprint_grow_finger_scan_matched
data:
finger_id: !lambda 'return finger_id;'
confidence: !lambda 'return confidence;'
- fingerprint_grow.aura_led_control:
state: BREATHING
speed: 200
color: BLUE
count: 1
- switch.turn_on: open_home_door
on_finger_scan_unmatched:
- homeassistant.event:
event: esphome.test_fingerprint_grow_finger_scan_unmatched
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: RED
count: 2
on_enrollment_scan:
- homeassistant.event:
event: esphome.test_fingerprint_grow_enrollment_scan
data:
finger_id: !lambda 'return finger_id;'
scan_num: !lambda 'return scan_num;'
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: BLUE
count: 2
on_enrollment_done:
- homeassistant.event:
event: esphome.test_fingerprint_grow_node_enrollment_done
data:
finger_id: !lambda 'return finger_id;'
- fingerprint_grow.aura_led_control:
state: BREATHING
speed: 100
color: BLUE
count: 2
on_enrollment_failed:
- homeassistant.event:
event: esphome.test_fingerprint_grow_enrollment_failed
data:
finger_id: !lambda 'return finger_id;'
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: RED
count: 4
switch:
- platform: template
name: "Open home door"
id: open_home_door
turn_on_action:
- stepper.report_position:
id: nema
position: 0
- output.turn_on: stepper_en
- if:
condition:
binary_sensor.is_on: door_state
then:
- stepper.set_target:
id: nema
target: !lambda |-
return id(steps_full)*-1 + id(steps_open_latch);
- wait_until:
lambda: return id(nema).current_position == id(steps_full)*-1 + id(steps_open_latch);
- delay: 2s
- stepper.set_target:
id: nema
target: -3200
- wait_until:
lambda: return id(nema).current_position == -3200;
else:
- stepper.set_target:
id: nema
target: -1288
- wait_until:
lambda: return id(nema).current_position == -1288;
- delay: 2s
- stepper.set_target:
id: nema
target: -100
- wait_until:
lambda: return id(nema).current_position == -200;
- output.turn_off: stepper_en
- switch.turn_off: open_home_door
- platform: template
name: "Close home door"
id: close_home_door
turn_on_action:
- if:
condition:
binary_sensor.is_off: door_state
then:
- script.execute: close_door
output:
- platform: esp8266_pwm
pin: D0
frequency: 1000 Hz
id: buzzer
- platform: gpio
pin: D4
inverted: True
id: stepper_en
rtttl:
output: buzzer
stepper:
- platform: a4988
id: nema
step_pin: D3
dir_pin: D2
max_speed: 3000 steps/s
acceleration: 5000
deceleration: 5000
sensor:
- platform: fingerprint_grow
fingerprint_count:
name: "Fingerprint Count"
status:
name: "Fingerprint Status"
capacity:
name: "Fingerprint Capacity"
security_level:
name: "Fingerprint Security Level"
last_finger_id:
name: "Fingerprint Last Finger ID"
last_confidence:
name: "Fingerprint Last Confidence"
binary_sensor:
- platform: fingerprint_grow
name: "Fingerprint Enrolling"
- platform: gpio
pin: D1
name: "Door Button"
on_click:
min_length: 100ms
then:
- rtttl.play: "one short:d=4,o=5,b=100:16e6"
- delay: 5s
- script.execute: close_door
- wait_until:
not:
script.is_running: close_door
- rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6"
- platform: gpio
pin: D8
name: "Door State ON is closed"
device_class: door
id: door_state
script:
- id: close_door
then:
- stepper.report_position:
id: nema
position: 0
- output.turn_on: stepper_en
- stepper.set_target:
id: nema
target: 3200
- wait_until:
lambda: return id(nema).current_position == 3200;
- output.turn_off: stepper_en
api:
services:
- service: fingerprint_grow_enroll
variables:
finger_id: int
num_scans: int
then:
- fingerprint_grow.enroll:
finger_id: !lambda 'return finger_id;'
num_scans: !lambda 'return num_scans;'
- service: fingerprint_grow_cancel_enroll
then:
- fingerprint_grow.cancel_enroll:
- service: fingerprint_grow_delete
variables:
finger_id: int
then:
- fingerprint_grow.delete:
finger_id: !lambda 'return finger_id;'
- service: fingerprint_grow_delete_all
then:
- fingerprint_grow.delete_all: