12V RGB LED Controller mit Bewegungsmelder (LOKAL! Funktioniert auch, wenn HA ausfällt!)
Dieses ESPHome Projekt ist ein einfacher Code, der bei Bewegung RGB LEDs einschaltet und nach einem Timeout (2 Minuten) wenn keine Bewegung mehr stattgefunden hat wieder abschaltet. Um die LEDs dauerhaft anzusch...
Code-Vorschau
Haupt-Konfiguration
Tipp: Markieren & ⌘/Ctrl + C zum Kopieren
configuration.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
esphome:name: rgb-led-mit-pir
platform: ESP8266
board: nodemcuv2
wifi:ssid:!secret WLanSSID
password:!secret WLanPassword
ap:ssid:"RGB-LED-PIR"password:"gWef1LGFbEILB"captive_portal:logger:api:ota:sun:latitude: 51.158672°
longitude: 7.196742°
time:-platform: homeassistant
id: local_time
binary_sensor:-platform: gpio
pin: D1
name:"Bewegungsmelder"device_class: motion
id: pir
on_press:then:-if:condition:-sun.is_below_horizon:then:-script.execute: switch_rgb_led_script
light:-platform: rgb
name:"RGB Led"red: rgb_led_red
green: rgb_led_green
blue: rgb_led_blue
id: rgb_led
output:-platform: esp8266_pwm
id: rgb_led_red
pin: D5
-platform: esp8266_pwm
id: rgb_led_green
pin: D6
-platform: esp8266_pwm
id: rgb_led_blue
pin: D2
# Helper um per HA das Abschalten per timeout generell zu verhindernswitch:-platform: gpio
pin: D3
name:"LEDs dauerhaft an"id: leds_daueran
on_turn_on:-light.turn_on: rgb_led
on_turn_off:-light.turn_off: rgb_led
# Script mit Mode=restart, damit der Timeout bei jeder erneuten Bewegung zurückgesetzt wird.# Wenn also das Licht eingeschaltet wurde, aber in den 2 Minuten delay erneut eine Bewegung erkannt wird, # wird das Script abgebrochen und neu gestartet, wodurch die 2 Minuten Wartezeit erneut beginnenscript:-id: switch_rgb_led_script
mode: restart
then:-light.turn_on: rgb_led
-delay: 2min
-if:condition:switch.is_off: leds_daueran
then:-light.turn_off: rgb_led