-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yaml
169 lines (147 loc) · 3.84 KB
/
config.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
substitutions:
friendly_name: Garage Door
esphome:
name: garage-opener
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Garage-Opener Fallback Hotspot"
password: !secret failback_password
captive_portal:
#This relay is wired to a pushbutton remote for the garage door opener
switch:
- platform: gpio
name: opener
pin:
number: GPIO23
inverted: False
id: opener
restore_mode: ALWAYS_OFF
internal: true
#Hardwired magnetic reed switch mounted to back of door track
binary_sensor:
- platform: gpio
name: "Open Sensor"
pin:
number: GPIO18
inverted: true
mode: INPUT_PULLUP
filters:
- delayed_on_off: 50ms
id: open_sensor
#Hardwired magnetic reed switch mounted to top of door
- platform: gpio
name: "Close Sensor"
pin:
number: GPIO26
inverted: true
mode: INPUT_PULLUP
filters:
- delayed_on_off: 50ms
id: close_sensor
#Deterministic sensor for vehicle occupancy
- platform: template
name: "Vehicle in Garage"
device_class: occupancy
lambda: |-
if (id(ultrasonic_sensor).state < 1) {
// Vehicle is in the garage
return true;
} else {
// No vehicle is in the garage
return false;
}
#Deterministic sensor for garage door status
- platform: template
name: "Garage Door Status"
device_class: garage_door
lambda: |-
if (id(close_sensor).state == false) {
// Garage door is closed
return true;
} else {
// Garage door is open
return false;
}
#Garage door opener configuration - opener --> relay --> pushbutton remote
cover:
- platform: feedback
device_class: garage
name: $friendly_name
has_built_in_endstop: true
open_action:
- switch.turn_on: opener
- delay: 0.5s
- switch.turn_off: opener
open_duration: 11s
open_endstop: open_sensor
close_action:
- switch.turn_on: opener
- delay: 0.5s
- switch.turn_off: opener
close_duration: 11s
close_endstop: close_sensor
stop_action:
- switch.turn_on: opener
- delay: 0.5s
- switch.turn_off: opener
sensor:
# Ultrasonic sensor to determine vehicle occupancy
- platform: ultrasonic
trigger_pin: GPIO16
echo_pin: GPIO17
name: "Ultrasonic Sensor"
update_interval: 5s
timeout: 3m
id: ultrasonic_sensor
# Send WiFi signal strength
- platform: wifi_signal
name: $friendly_name WiFi Strength
update_interval: 60s
# Send uptime to HA
- platform: uptime
internal: true
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
# Send IP Address to HA
text_sensor:
- platform: wifi_info
ip_address:
name: $friendly_name IP Address
- platform: template
name: $friendly_name Uptime
id: uptime_human
icon: mdi:clock-start