Letzter täglicher Build
Build erfolgreich
Zuletzt gebaut: 01.09.2026, 15:14
Build-Details & Log anzeigenthumb.png
1368.2 KB
1esphome:
2 name: garage-door-with-rgb-led
3 friendly_name: Garage mit RGB LEDs
4
5esp8266:
6 board: d1_mini
7
8wifi:
9 ssid: "WiFi_SSID"
10 password: "WiFi_Password123"
11
12 ap:
13 ssid: "garagentorWiFi"
14 password: "123456789"
15
16captive_portal:
17logger:
18
19api:
20
21ota:
22 - platform: esphome
23 password: "TopSecretSuperPasswort"
24
25globals:
26
27# -----------------------------
28# -------- CONFIG START -------
29# -----------------------------
30# Breite des Balkens bei Animationen der LEDs
31 - id: ANIM_BREITE
32 type: int
33 restore_value: no
34 initial_value: '15'
35
36# Geschwindigkeit der Animation (kleiner = schneller)
37 - id: DEFAULT_DELAY
38 type: int
39 restore_value: no
40 initial_value: '14'
41
42# Angabe wie viele Sekunden die Spots anbleiben sollen
43 - id: shutoff_delay_spots
44 type: int
45 restore_value: no
46 initial_value: '120'
47
48# -----------------------------
49# -------- CONFIG ENDE --------
50# -----------------------------
51
52
53
54# INTERNE VARIABLEN! NICHT ÄNDERN!
55 - id: led_pos
56 type: int
57 restore_value: no
58 initial_value: '0'
59 - id: forward
60 type: bool
61 restore_value: no
62 initial_value: 'true'
63
64
65
66script:
67# Programmablauf während Tor sich öffnet
68 - id: door_opening
69 mode: restart
70 then:
71 - script.execute: stop_running_end_scripts
72 - light.turn_on:
73 id: garagentor_leds
74 effect: "Tor in Bewegung"
75 - delay: 60s
76 - light.turn_off:
77 id: garagentor_leds
78
79
80# Programmablauf wenn Tor vollständig geöffnet wurde
81 - id: door_opened
82 mode: restart
83 then:
84 - script.execute: stop_running_moving_scripts
85 - light.turn_on:
86 id: garagentor_leds
87 effect: "Tor fertig"
88 - delay: 11s
89 - light.turn_on:
90 id: garagentor_leds
91 effect: "Activate Spots"
92 - delay: !lambda 'return id(shutoff_delay_spots)*1000;'
93 - light.turn_off: garagentor_leds
94
95
96# Programmablauf während Tor sich schließt
97 - id: door_closing
98 mode: restart
99 then:
100 - script.execute: stop_running_end_scripts
101 - light.turn_on:
102 id: garagentor_leds
103 effect: "Tor in Bewegung"
104 - delay: 60s
105 - light.turn_off:
106 id: garagentor_leds
107
108# Programmablauf wenn Tor vollständig geschlossen wurde
109 - id: door_closed
110 mode: restart
111 then:
112 - script.execute: stop_running_moving_scripts
113 - light.turn_on:
114 id: garagentor_leds
115 effect: "Tor fertig"
116 - delay: 11s
117 - light.turn_on:
118 id: garagentor_leds
119 effect: "Activate Spots"
120 - delay: !lambda 'return id(shutoff_delay_spots)*1000;'
121 - light.turn_off: garagentor_leds
122
123
124# ggf. aktive Scripte stoppen
125 - id: stop_running_end_scripts
126 mode: restart
127 then:
128 - if:
129 condition:
130 - script.is_running: door_opened
131 then:
132 - script.stop: door_opened
133 - if:
134 condition:
135 - script.is_running: door_closed
136 then:
137 - script.stop: door_closed
138
139 - id: stop_running_moving_scripts
140 mode: restart
141 then:
142 - if:
143 condition:
144 - script.is_running: door_opening
145 then:
146 - script.stop: door_opening
147 - if:
148 condition:
149 - script.is_running: door_closing
150 then:
151 - script.stop: door_closing
152
153
154
155
156switch:
157# Relais für Signal an Motor
158# mit on_turn_on automatisch wieder abschalten
159 - platform: gpio
160 name: "Carport Tor"
161 id: garagentor_tor_relais
162 pin: D7
163 on_turn_on:
164 - delay: 1s
165 - switch.turn_off: garagentor_tor_relais
166
167
168
169binary_sensor:
170# Reed-Kontakt für Tor vollständig geöffnet
171 - platform: gpio
172 name: "Carport Tor Offen"
173 device_class: garage_door
174 id: garagentor_tor_open_sensor
175 pin:
176 number: D5
177 inverted: true
178 filters:
179 - delayed_off: 500ms
180 - delayed_on: 100ms
181 on_release:
182 - text_sensor.template.publish:
183 id: garagentor_tor_status
184 state: "Geöffnet"
185 - script.execute: door_opened
186 on_press:
187 - text_sensor.template.publish:
188 id: garagentor_tor_status
189 state: "Tor schließt sich"
190 - script.execute: door_closing
191
192# Reed-Kontakt für Tor vollständig geschlossen
193 - platform: gpio
194 name: "Carport Tor geschlossen"
195 device_class: garage_door
196 id: garagentor_tor_closed_sensor
197 pin:
198 number: D6
199 inverted: true
200 filters:
201 - delayed_off: 500ms
202 - delayed_on: 100ms
203 on_release:
204 - text_sensor.template.publish:
205 id: garagentor_tor_status
206 state: "Geschlossen"
207 - script.execute: door_closed
208 on_press:
209 - text_sensor.template.publish:
210 id: garagentor_tor_status
211 state: "Tor öffnet sich"
212 - script.execute: door_opening
213
214# Taster zur manuellen Bedienung des Tores
215# schaltet bei Druck das Relais
216 - platform: gpio
217 name: "Garagentor Tor Taster"
218 id: garagentor_tor_btn
219 pin: D1
220 filters:
221 - delayed_off: 500ms
222 on_press:
223 then:
224 - switch.turn_on: garagentor_tor_relais
225 on_release:
226 then:
227 - switch.turn_off: garagentor_tor_relais
228
229
230text_sensor:
231 - platform: template
232 name: "Garagentor Tor-Status"
233 id: garagentor_tor_status
234 lambda: |-
235 if(!id(garagentor_tor_closed_sensor).state){
236 return {"Geschlossen"};
237 } else if (!id(garagentor_tor_open_sensor).state){
238 return {"Geöffnet"};
239 } else {
240 return {"In Bewegung"};
241 }
242 update_interval: 120s
243
244
245light:
246
247
248 - platform: neopixelbus
249 type: GRB
250 variant: WS2812
251 name: "Garagentor LEDs"
252 id: garagentor_leds
253 pin: D2
254 num_leds: 150
255 default_transition_length: 1s
256 restore_mode: ALWAYS_OFF
257
258 effects:
259 - addressable_rainbow:
260 name: Rainbow
261 speed: 10
262 width: 20
263
264# Animation: 2 rote Blöcke laufen entgegengesetzt hin und her
265 - addressable_lambda:
266 name: "Tor in Bewegung"
267 update_interval: 16ms
268 lambda: |-
269 static const int16_t LAST = it.size()-1;
270
271 static int16_t pos2 = 0;
272
273 if (initial_run) {
274 id(led_pos) = 0;
275 id(forward) = true;
276 }
277
278 pos2 = LAST - id(ANIM_BREITE) - id(led_pos) +1;
279
280 if(id(forward)){
281 if(id(led_pos) > 0){
282 it[id(led_pos)-1] = esphome::Color(0,0,0);
283 it[pos2+id(ANIM_BREITE)] = esphome::Color(0,0,0);
284 }
285
286 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,0,0);
287 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,0,0);
288
289 if(id(led_pos) < (LAST - id(ANIM_BREITE)) + 1){
290 id(led_pos)++;
291 } else {
292 id(forward) = false;
293 }
294
295 } else {
296 if(id(led_pos) < (LAST - id(ANIM_BREITE)) +1){
297 it[id(led_pos)+id(ANIM_BREITE)] = esphome::Color(0,0,0);
298 it[pos2-1] = esphome::Color(0,0,0);
299 }
300
301 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,0,0);
302 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,0,0);
303
304 if(id(led_pos) > 0){
305 id(led_pos)--;
306 } else {
307 id(forward) = true;
308 }
309 }
310
311 delay(id(DEFAULT_DELAY));
312
313
314
315# Animation:
316# - LEDs blenden von aussen nach innen vollständig auf rot
317# - LEDs blenden über in grün
318 - addressable_lambda:
319 name: "Tor fertig"
320 update_interval: 16ms
321 lambda: |-
322 static const int16_t LAST = it.size()-1;
323
324 static boolean prepare = true;
325 static boolean blendInRed = true;
326 static int16_t pos2 = 0;
327 static uint8_t r = 255;
328
329 if (initial_run) {
330 r = 255;
331 blendInRed = true;
332 prepare = id(led_pos)>0;
333 }
334
335 pos2 = LAST - id(ANIM_BREITE) - id(led_pos) +1;
336
337 if(prepare){
338 if(id(forward)){
339 if(id(led_pos) > 0){
340 it[id(led_pos)-1] = esphome::Color(0,0,0);
341 it[pos2+id(ANIM_BREITE)] = esphome::Color(0,0,0);
342 }
343
344 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,0,0);
345 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,0,0);
346
347 if(id(led_pos) < (LAST - id(ANIM_BREITE)) +1){
348 id(led_pos)++;
349 } else {
350 id(forward) = false;
351 }
352
353 } else {
354 if(id(led_pos) < (LAST - id(ANIM_BREITE)) +1){
355 it[id(led_pos)+id(ANIM_BREITE)] = esphome::Color(0,0,0);
356 it[pos2-1] = esphome::Color(0,0,0);
357 }
358
359 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,0,0);
360 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,0,0);
361
362 if(id(led_pos) > 0){
363 id(led_pos)--;
364 } else {
365 prepare = false;
366 }
367 }
368
369 delay(id(DEFAULT_DELAY));
370
371 } else {
372 if(blendInRed){
373 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(r,0,0);
374 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(r,0,0);
375
376 if(id(led_pos) < (LAST - id(ANIM_BREITE)) +1){
377 id(led_pos)++;
378 } else {
379 blendInRed = false;
380 }
381 delay(id(DEFAULT_DELAY));
382
383 } else {
384 it.all() = esphome::Color(r, 255-r, 0);
385 if(r>0){
386 r=r-5;
387 }
388 delay(2);
389
390 }
391 }
392
393# Animation:
394# - LEDs blenden in 4 Schritten vollständig auf Weißes Licht ein
395# (Lauflicht mit abwechselnder Richtung, wobei jeder Durchlauf heller wird)
396# - Überblendung zu Spots durch weiße laufende Spots die die vollständige Beleuchtung "ausradieren"
397 - addressable_lambda:
398 name: "Activate Spots"
399 update_interval: 16ms
400 lambda: |-
401 static const int16_t LAST = it.size()-1;
402
403 static boolean forward = true;
404 static boolean ready = false;
405 static int16_t pos2 = 0;
406 static int16_t colorVal = 0;
407
408 if (initial_run) {
409 ready = false;
410 id(led_pos) = 0;
411 colorVal = 127;
412 }
413
414 pos2 = LAST - id(ANIM_BREITE) - id(led_pos) +1;
415
416 if(!ready){
417 if(forward){
418 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(colorVal, colorVal, colorVal);
419 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(colorVal, colorVal, colorVal);
420
421 if(id(led_pos) < (LAST/2) - id(ANIM_BREITE) +1){
422 id(led_pos)++;
423 } else {
424 forward = false;
425 colorVal = colorVal+64;
426 }
427
428 } else {
429 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(colorVal, colorVal, colorVal);
430 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(colorVal, colorVal, colorVal);
431
432 if(id(led_pos) > 0){
433 id(led_pos)--;
434 } else {
435 forward = true;
436 colorVal = colorVal+64;
437 if(colorVal >= 191){
438 ready = true;
439 }
440 }
441 }
442 } else {
443 if(forward){
444 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,255,255);
445 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,255,255);
446
447 if(id(led_pos) < (LAST - id(ANIM_BREITE)*2) + 1){
448 if(id(led_pos) > 0){
449 it[id(led_pos)-1] = esphome::Color(0,0,0);
450 it[pos2+id(ANIM_BREITE)] = esphome::Color(0,0,0);
451 }
452 id(led_pos)++;
453 } else {
454 if(id(led_pos) < (LAST - id(ANIM_BREITE)) +1){
455 it[id(led_pos)+id(ANIM_BREITE)] = esphome::Color(0,0,0);
456 it[pos2-1] = esphome::Color(0,0,0);
457 }
458
459 it.range(id(led_pos), id(led_pos) + id(ANIM_BREITE)) = esphome::Color(255,255,255);
460 it.range(pos2, pos2 + id(ANIM_BREITE)) = esphome::Color(255,255,255);
461
462 if(id(led_pos) > id(ANIM_BREITE)+1){
463 id(led_pos)--;
464 }
465 }
466 }
467 }
468
469 delay(id(DEFAULT_DELAY));