-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarage_door.yaml
246 lines (221 loc) · 5.87 KB
/
garage_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
242
243
244
245
246
# -------------------------------------
# ---- Garage Door module ----
# -------------------------------------
substitutions:
devicename: garage_door
open_combo: !secret open_combo
distance_door_open: "0.7"
distance_car: "1.3"
esphome:
name: ${devicename}
platform: ESP8266
board: nodemcuv2
wifi:
#power_save_mode: light # power reduced from 1.2w to 0.8w
#fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_garage_door
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${devicename} Hotspot"
password: !secret password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s # Dont reboot..
encryption:
key: !secret encryption_key
ota:
password: !secret password
# NO WEB SERVER!!!!
#web_server:
# port: 80
# auth:
# username: admin
# password: !secret password
# Dam thing always flashes
#status_led:
# pin:
# number: GPIO16
# inverted: True
# https://blog.lesman.com/2012/01/27/best-location-for-installing-ultrasonic-level-transducer/
sensor:
- platform: ultrasonic
id: door1_ultrasonic
name: "${devicename} Door 1 Distance"
trigger_pin: GPIO14 # D4 on ESP8266
echo_pin: GPIO4 # D2 on ESP8266
update_interval: 10s
pulse_time: 15us
timeout: 3m
filters:
- filter_out: nan
- platform: ultrasonic
id: door2_ultrasonic
name: "${devicename} Door 2 Distance"
trigger_pin: GPIO14 # D4 on ESP8266
echo_pin: GPIO5 # D1 on ESP8266
update_interval: 10s
pulse_time: 15us
timeout: 3m
filters:
- filter_out: nan
- platform: ultrasonic
id: door3_ultrasonic
name: "${devicename} Door 3 Distance"
trigger_pin: GPIO14 # D4 on ESP8266
echo_pin: GPIO0 # D3 on ESP8266
update_interval: 10s
pulse_time: 15us
timeout: 3m
filters:
- filter_out: nan
- platform: dht
pin: GPIO13 # D7 on ESP8266
model: AM2302
temperature:
name: "${devicename} Temperature"
humidity:
name: "${devicename} Humidity"
update_interval: 5min
switch:
- platform: gpio
id: door1_relay
#name: "Garage 1 Relay" #Do not set a name and it will keep internal
internal: True
pin:
# number: GPIO12 # D6 on ESP8266
number: GPIO10 # SD3 on ESP8266
inverted: True
- platform: gpio
id: door2_relay
#name: "Garage 2 Relay" #Do not set a name and it will keep internal
internal: True
pin:
number: GPIO3 # RX on ESP8266
inverted: True
- platform: gpio
id: door3_relay
#name: "Garage 3 Relay" #Do not set a name and it will keep internal
internal: True
pin:
number: GPIO12 # D6 on ESP8266
inverted: True
cover:
- platform: template
id: door1_cover
name: "${devicename} Door 1"
device_class: garage
lambda: |-
if (id(door1_ultrasonic).state < $distance_door_open) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
optimistic: true
close_action:
if:
condition:
lambda: 'return (id(door1_cover).position == COVER_OPEN);'
then:
- logger.log: "Door1 Closing!"
- switch.turn_on: door1_relay
- delay: 0.1s
- switch.turn_off: door1_relay
else:
- logger.log: "Door1 Not Open!"
- platform: template
id: door2_cover
name: "${devicename} Door 2"
device_class: garage
lambda: |-
if (id(door2_ultrasonic).state < $distance_door_open) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
optimistic: true
close_action:
if:
condition:
lambda: 'return (id(door2_cover).position == COVER_OPEN);'
then:
- logger.log: "Door2 Closing!"
- switch.turn_on: door2_relay
- delay: 0.1s
- switch.turn_off: door2_relay
else:
- logger.log: "Door2 Not Open!"
- platform: template
id: door3_cover
name: "${devicename} Door 3"
device_class: garage
lambda: |-
if (id(door3_ultrasonic).state < $distance_door_open) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
optimistic: true
close_action:
if:
condition:
lambda: 'return (id(door3_cover).position == COVER_OPEN);'
then:
- logger.log: "Door3 Closing!"
- switch.turn_on: door3_relay
- delay: 0.1s
- switch.turn_off: door3_relay
else:
- logger.log: "Door3 Not Open!"
binary_sensor:
- platform: template
name: "${devicename} 1 Car"
device_class: presence
lambda: |-
if (id(door1_ultrasonic).state < $distance_door_open) {
// door open and cannot check for car
return {};
} else if (id(door1_ultrasonic).state < $distance_car) {
// car is in the garage
return true;
} else {
// no car
return false;
}
- platform: template
name: "${devicename} 2 Car"
device_class: presence
lambda: |-
if (id(door2_ultrasonic).state < $distance_door_open) {
// door open and cannot check for car
return {};
} else if (id(door2_ultrasonic).state < $distance_car) {
// car is in the garage
return true;
} else {
// no car
return false;
}
- platform: template
name: "${devicename} 3 Car"
device_class: presence
lambda: |-
if (id(door3_ultrasonic).state < $distance_door_open) {
// door open and cannot check for car
return {};
} else if (id(door3_ultrasonic).state < $distance_car) {
// car is in the garage
return true;
} else {
// no car
return false;
}