forked from athom-tech/esp32-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathathom-garage-door.yaml
224 lines (198 loc) · 4.95 KB
/
athom-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
substitutions:
name: "athom-garage-door"
friendly_name: "Athom Garage Door"
room: ""
device_description: "athom esp32-c3 garage door opener"
project_name: "Athom Technology.Garage Door Opener"
project_version: "v2.0.2"
dns_domain: ""
timezone: ""
wifi_fast_connect: "false"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
area: "${room}"
name_add_mac_suffix: true
min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
platformio_options:
board_build.mcu: esp32c3
board_build.variant: esp32c3
board_build.flash_mode: dio
esp32:
board: esp32-c3-devkitm-1
flash_size: 4MB
variant: ESP32C3
framework:
type: arduino
version: recommended
api:
ota:
- platform: esphome
logger:
mdns:
disabled: false
web_server:
port: 80
wifi:
ap: {}
fast_connect: "${wifi_fast_connect}"
domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/esp32-configs/athom-garage-door.yaml
sensor:
- platform: uptime
name: "Uptime Sensor"
id: uptime_sensor
entity_category: diagnostic
internal: true
- platform: wifi_signal
name: "WiFi Signal"
id: wifi_signal_db
update_interval: 60s
entity_category: diagnostic
internal: true
- platform: copy
source_id: wifi_signal_db
name: "WiFi Strength"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: diagnostic
binary_sensor:
- platform: status
name: "Status"
- platform: gpio
name: "Contact"
disabled_by_default: true
device_class: garage_door
id: contact
pin:
number: GPIO18
inverted: true
filters:
- delayed_on: 20ms
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "Button"
disabled_by_default: true
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.turn_on: relay
- timing:
- ON for at least 4s
then:
- button.press: Reset
button:
- platform: restart
name: "Restart"
entity_category: config
- platform: factory_reset
name: "Factory Reset"
id: Reset
entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
entity_category: config
switch:
- platform: gpio
pin: GPIO7
name: "Relay"
id: relay
disabled_by_default: true
on_turn_on:
- light.turn_on: wifi_led
- delay: 1s
- switch.turn_off: relay
- light.turn_off: wifi_led
light:
- platform: status_led
name: "Status LED"
id: wifi_led
disabled_by_default: true
pin: GPIO4
cover:
- platform: template
device_class: garage
name: "Garage Door"
lambda: "return id(contact).state ? COVER_OPEN : COVER_CLOSED;"
open_action:
then:
- if:
condition:
lambda: 'return !id(contact).state;'
then:
- switch.turn_on: relay
stop_action:
- switch.turn_on: relay
close_action:
then:
- if:
condition:
lambda: 'return id(contact).state;'
then:
- switch.turn_on: relay
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
entity_category: diagnostic
ssid:
name: "Connected SSID"
entity_category: diagnostic
mac_address:
name: "Mac Address"
entity_category: diagnostic
- platform: template
name: 'Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
device_class: timestamp
- platform: template
name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
icon: mdi:clock-start
time:
- platform: sntp
id: sntp_time
timezone: "${timezone}"
update_interval: 360min
on_time_sync:
then:
- if:
condition:
lambda: 'return id(device_last_restart).state == "";'
then:
- text_sensor.template.publish:
id: device_last_restart
state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'