Es wird mal wieder Zeit um ein kleines neues Projekt vorzustellen:
POWER WLED AMPEL mit ESP32 und Homeassistant !
Hier habe ich mich dazu entschieden das ganze mit 10 WLED (Chip WS2812; 5V) umzusetzen
Eine WLED benötigt 0,3 W, damit verbrauchen alle 10 zusammen 3W
Bei 5V wären es dann 0,6 A, damit kann er ohne weiteres direkt am ESP32 betrieben werden
Den WLED Streifen (10 LED) habe ich dann an VIN (5V), GND und Datenleitung an GPIO12 angeschlossen:
Mit ESPHome habe ich dann die 10 adressierbaren LED mit Light (platform: fastled_clockless) eingebunden.
Hier mal der Code von mir:
- 10 einzeln schaltbare LED mit jeweils 2 Strobo Effekten mit Rot und Grün.
# WS2812 LED
#light:
- platform: fastled_clockless
chipset: WS2812
id: light_fastled
pin: GPIO12
num_leds: 10
rgb_order: GRB
name: "WLED"
- platform: partition
name: "PL01"
segments:
- id: light_fastled
from: 0
to: 0
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL02"
segments:
- id: light_fastled
from: 1
to: 1
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL03"
segments:
- id: light_fastled
from: 2
to: 2
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL04"
segments:
- id: light_fastled
from: 3
to: 3
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL05"
segments:
- id: light_fastled
from: 4
to: 4
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL06"
segments:
- id: light_fastled
from: 5
to: 5
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL07"
segments:
- id: light_fastled
from: 6
to: 6
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL08"
segments:
- id: light_fastled
from: 7
to: 7
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL09"
segments:
- id: light_fastled
from: 8
to: 8
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- platform: partition
name: "PL10"
id: PL10
segments:
- id: light_fastled
from: 9
to: 9
effects:
- strobe:
name: Strobe Rot
colors:
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Grün
colors:
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
Alles anzeigen
Und so erscheint es das dann in Homeassistant:
Homeassistant Steuerelemente.jpg
Jetzt hatte ich viel Spaß mit der passenden Automatisierung (bzw. 2)
Als Skalierung habe ich mich für 100W Schritte entschieden:
Bei Verbrauch (Netzbezug und Entitäts ID positiv)
Je 100 W wird eine weitere LED in Rot zugeschaltet und ab 1000W dann einfach alle in Rot blinkend.
Bei Einspeisung (Netzeinspeisung und Entitäts ID positiv)
Je 100 W wird eine weitere LED in Grün zugeschaltet und ab 1000W dann einfach alle in Grün blinkend.
Hier dann mal die beiden Automationen:
alias: Power Ampel Verbrauch WLED
description: ""
trigger:
- platform: template
value_template: "{{ 10000 > states('sensor.verbrauch_power')|float(0) >= 1000 }}"
id: V_1000-10000
- platform: template
value_template: "{{ 1000 > states('sensor.verbrauch_power')|float(0) >= 900 }}"
id: V_900-1000
- platform: template
value_template: "{{ 900 > states('sensor.verbrauch_power')|float(0) >= 800 }}"
id: V_800-900
- platform: template
value_template: "{{ 800 > states('sensor.verbrauch_power')|float(0) >= 700 }}"
id: V_700-800
- platform: template
value_template: "{{ 700 > states('sensor.verbrauch_power')|float(0) >= 600 }}"
id: V_600-700
- platform: template
value_template: "{{ 600 > states('sensor.verbrauch_power')|float(0) >= 500 }}"
id: V_500-600
- platform: template
value_template: "{{ 500 > states('sensor.verbrauch_power')|float(0) >= 400 }}"
id: V_400-500
- platform: template
value_template: "{{ 400 > states('sensor.verbrauch_power')|float(0) >= 300 }}"
id: V_300-400
- platform: template
value_template: "{{ 300 > states('sensor.verbrauch_power')|float(0) >= 200 }}"
id: V_200-300
- platform: template
value_template: "{{ 200 > states('sensor.verbrauch_power')|float(0) >= 100 }}"
id: V_100-200
- platform: template
value_template: "{{ 100 > states('sensor.verbrauch_power')|float(0) >= 000 }}"
id: V_000-100
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- V_1000-10000
sequence:
- service: light.turn_on
metadata: {}
data:
effect: Strobe Rot
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_900-1000
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_800-900
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_700-800
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- conditions:
- condition: trigger
id:
- V_600-700
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- conditions:
- condition: trigger
id:
- V_500-600
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- conditions:
- condition: trigger
id:
- V_400-500
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- conditions:
- condition: trigger
id:
- V_300-400
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- conditions:
- condition: trigger
id:
- V_200-300
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- conditions:
- condition: trigger
id:
- V_100-200
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- light.esp32_3_pl03
- conditions:
- condition: trigger
id:
- V_000-100
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: red
effect: None
target:
entity_id:
- light.esp32_3_pl01
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- light.esp32_3_pl03
- light.esp32_3_pl02
mode: restart
Alles anzeigen
und
alias: Power Ampel WLED Einspeisung
description: ""
trigger:
- platform: template
value_template: "{{ 10000 > states('sensor.einspeisung_power')|float(0) >= 1000 }}"
id: V_1000-10000
- platform: template
value_template: "{{ 1000 > states('sensor.einspeisung_power')|float(0) >= 900 }}"
id: V_900-1000
- platform: template
value_template: "{{ 900 > states('sensor.einspeisung_power')|float(0) >= 800 }}"
id: V_800-900
- platform: template
value_template: "{{ 800 > states('sensor.einspeisung_power')|float(0) >= 700 }}"
id: V_700-800
- platform: template
value_template: "{{ 700 > states('sensor.einspeisung_power')|float(0) >= 600 }}"
id: V_600-700
- platform: template
value_template: "{{ 600 > states('sensor.einspeisung_power')|float(0) >= 500 }}"
id: V_500-600
- platform: template
value_template: "{{ 500 > states('sensor.einspeisung_power')|float(0) >= 400 }}"
id: V_400-500
- platform: template
value_template: "{{ 400 > states('sensor.einspeisung_power')|float(0) >= 300 }}"
id: V_300-400
- platform: template
value_template: "{{ 300 > states('sensor.einspeisung_power')|float(0) >= 200 }}"
id: V_200-300
- platform: template
value_template: "{{ 200 > states('sensor.einspeisung_power')|float(0) >= 100 }}"
id: V_100-200
- platform: template
value_template: "{{ 100 > states('sensor.einspeisung_power')|float(0) >= 000 }}"
id: V_000-100
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- V_1000-10000
sequence:
- service: light.turn_on
metadata: {}
data:
effect: Strobe Grün
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_900-1000
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_800-900
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- light.esp32_3_pl09
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- conditions:
- condition: trigger
id:
- V_700-800
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- light.esp32_3_pl08
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- conditions:
- condition: trigger
id:
- V_600-700
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- light.esp32_3_pl07
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- conditions:
- condition: trigger
id:
- V_500-600
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- light.esp32_3_pl06
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- conditions:
- condition: trigger
id:
- V_400-500
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- light.esp32_3_pl05
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- conditions:
- condition: trigger
id:
- V_300-400
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- light.esp32_3_pl04
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- conditions:
- condition: trigger
id:
- V_200-300
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- light.esp32_3_pl03
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- conditions:
- condition: trigger
id:
- V_100-200
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- light.esp32_3_pl02
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- light.esp32_3_pl03
- conditions:
- condition: trigger
id:
- V_000-100
sequence:
- service: light.turn_on
metadata: {}
data:
color_name: green
effect: None
target:
entity_id:
- light.esp32_3_pl01
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.esp32_3_pl10
- light.esp32_3_pl09
- light.esp32_3_pl08
- light.esp32_3_pl07
- light.esp32_3_pl06
- light.esp32_3_pl05
- light.esp32_3_pl04
- light.esp32_3_pl03
- light.esp32_3_pl02
mode: restart
Alles anzeigen
Da ich zurzeit auch ein ADS1115 (4-Channel 16-Bit AD) und ein INA219 (DC Current) an diesem ESP32 habe mal zur Vollständigkeit die interessanten Daten:
(Also kein Problem diesen direkt am ESP32 zu Betreiben)
(Current gemessen mit INA219 Bus Voltage 12,36 V am Netzteil)
Das war mein TAG
Gruß Andreas