-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
garage-door.yaml
188 lines (180 loc) · 5.24 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
---
substitutions:
name: garage-door
friendly_name: Garage Door
margin_of_error: "0.05"
packages:
common: !include modules/common-32-s3-idf.yaml
wifi: !include modules/common/wifi.yaml
konnected-gdo: !include modules/devices/konnected-GDO-v2.yaml
esphome:
on_boot:
priority: -1000
then:
- delay: 1s
- if:
condition:
binary_sensor.is_off: contact
then:
- component.suspend: range_sensor
else:
- cover.template.publish:
id: garage_door
state: CLOSED
current_operation: IDLE
number:
- platform: template
name: Sensor calibration
id: open_distance
icon: mdi:ruler
entity_category: config
unit_of_measurement: m
device_class: distance
step: 0.01
max_value: 2.0
min_value: 0.1
optimistic: true
restore_value: true
binary_sensor:
- platform: template
id: garage_door_open
name: Door Open Sensor
entity_category: diagnostic
device_class: garage_door
lambda: |-
float calibrated_distance = id(open_distance).state;
if (std::isnan(id(range_sensor).state)) {
return false;
} else if (id(range_sensor).state > (calibrated_distance + $margin_of_error)) {
return false;
} else if (id(range_sensor).state > (calibrated_distance - $margin_of_error)) {
return true;
}
return {};
filters:
- delayed_on: 1.5s
on_press:
- cover.template.publish:
id: garage_door
state: OPEN
current_operation: IDLE
on_release:
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: CLOSING
- id: !extend contact
name: Door Closed Sensor
entity_category: diagnostic
device_class: garage_door
on_press:
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: OPENING
- component.resume: range_sensor
on_release:
- cover.template.publish:
id: garage_door
state: CLOSED
current_operation: IDLE
- component.suspend: range_sensor
button:
- platform: output
id: opener_button
output: opener
duration: 300ms
internal: true
cover:
- platform: template
name: None
id: garage_door
device_class: garage
has_position: true
open_action:
- if:
condition:
lambda: |-
return (
id(garage_door).position == 0.5 &&
id(garage_door).current_operation ==
CoverOperation::COVER_OPERATION_IDLE
);
then:
- button.press: opener_button
- delay: 500ms
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: OPENING
- if:
condition:
lambda: |-
return (
id(garage_door).position != COVER_OPEN &&
id(garage_door).current_operation !=
CoverOperation::COVER_OPERATION_OPENING
);
then:
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: OPENING
close_action:
- if:
condition:
lambda: |-
return id(garage_door).current_operation ==
CoverOperation::COVER_OPERATION_OPENING;
then:
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: IDLE
- delay: 500ms
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: CLOSING
else:
- if:
condition:
lambda: |-
return (
id(garage_door).position != COVER_CLOSED &&
id(garage_door).current_operation !=
CoverOperation::COVER_OPERATION_CLOSING
);
then:
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: CLOSING
stop_action:
- if:
condition:
lambda: |-
return id(garage_door).current_operation ==
CoverOperation::COVER_OPERATION_OPENING;
then:
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: IDLE
- if:
condition:
lambda: |-
return id(garage_door).current_operation ==
CoverOperation::COVER_OPERATION_CLOSING;
then:
- button.press: opener_button
- cover.template.publish:
id: garage_door
position: 0.5
current_operation: OPENING