Introduced the light component.

Adopted rgb_light.
Added brightness based on photodiode voltage.
Added warn levels for particle dust.
Removed actions out of sensors. Will be replaced by actions based on warn lavels.

All values (brightness / colors / voltage) still uncalibrated.
This commit is contained in:
Marcus Scholz 2021-09-03 17:39:32 +02:00
parent c6501d3691
commit 3903d60c74

View File

@ -3,19 +3,19 @@ esphome:
platform: ESP32 platform: ESP32
board: nodemcu-32s board: nodemcu-32s
# Dirty hack, because on_value_range does not trigger green if sensor # # Dirty hack, because on_value_range does not trigger green if sensor
# value is within green range on boot. # # value is within green range on boot.
on_boot: # on_boot:
then: # then:
- output.set_level: # - output.set_level:
id: led_green # id: led_green
level: 58% # level: 58%
- output.set_level: # - output.set_level:
id: led_red # id: led_red
level: 0% # level: 0%
- text_sensor.template.publish: # - text_sensor.template.publish:
id: co2_warn # id: co2_warn
state: "grün" # state: "grün"
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
@ -57,10 +57,20 @@ output:
- platform: ledc - platform: ledc
pin: GPIO18 pin: GPIO18
id: led_green id: led_green
max_power: 50%
- platform: ledc - platform: ledc
pin: GPIO19 pin: GPIO19
id: led_blue id: led_blue
# Example configuration entry
light:
- platform: rgb
id: co2_light
name: "CO2 Status LED"
red: led_red
green: led_green
blue: led_blue
# Initialize UART for Vindriktning sensor # Initialize UART for Vindriktning sensor
uart: uart:
rx_pin: GPIO26 rx_pin: GPIO26
@ -71,6 +81,9 @@ text_sensor:
- platform: template - platform: template
name: "Schlafzimmer CO2 Warnstufe" name: "Schlafzimmer CO2 Warnstufe"
id: co2_warn id: co2_warn
- platform: template
name: "Schlafzimmer Feinstaub Warnstufe"
id: pm25_warn
sensor: sensor:
# WiFi signal strength # WiFi signal strength
@ -92,47 +105,23 @@ sensor:
- above: 380 - above: 380
below: 800 below: 800
then: then:
- output.set_level:
id: led_green
level: 58%
- output.set_level:
id: led_red
level: 0%
- text_sensor.template.publish: - text_sensor.template.publish:
id: co2_warn id: co2_warn
state: "grün" state: "grün"
- above: 800 - above: 800
below: 1200 below: 1200
then: then:
- output.set_level:
id: led_green
level: 58%
- output.set_level:
id: led_red
level: 80%
- text_sensor.template.publish: - text_sensor.template.publish:
id: co2_warn id: co2_warn
state: "gelb" state: "gelb"
- above: 1200 - above: 1200
below: 1600 below: 1600
then: then:
- output.set_level:
id: led_green
level: 50%
- output.set_level:
id: led_red
level: 100%
- text_sensor.template.publish: - text_sensor.template.publish:
id: co2_warn id: co2_warn
state: "orange" state: "orange"
- above: 1600 - above: 1600
then: then:
- output.set_level:
id: led_green
level: 0%
- output.set_level:
id: led_red
level: 100%
- text_sensor.template.publish: - text_sensor.template.publish:
id: co2_warn id: co2_warn
state: "rot" state: "rot"
@ -161,6 +150,24 @@ sensor:
- platform: pm1006 - platform: pm1006
pm_2_5: pm_2_5:
name: "Feinstaub PM 2.5µm" name: "Feinstaub PM 2.5µm"
on_value_range:
- above: 0
below: 35
then:
- text_sensor.template.publish:
id: pm25_warn
state: "grün"
- above: 35
below: 85
then:
- text_sensor.template.publish:
id: pm25_warn
state: "orange"
- above: 85
then:
- text_sensor.template.publish:
id: pm25_warn
state: "rot"
# Analog photo diode voltage # Analog photo diode voltage
- platform: adc - platform: adc
pin: 32 pin: 32
@ -168,6 +175,17 @@ sensor:
attenuation: 11db attenuation: 11db
update_interval: 1s update_interval: 1s
internal: true internal: true
on_value_range:
- below: 0.3
then:
light.turn_on:
id: co2_light
brightness: 50%
- above: 0.3
then:
light.turn_on:
id: co2_light
brightness: 100%
# IR Receiver, dumps all received values into serial # IR Receiver, dumps all received values into serial
remote_receiver: remote_receiver: