2023-05-27 16:52:05 +02:00
|
|
|
substitutions:
|
|
|
|
name: "livingroom"
|
|
|
|
friendly_name: "Luftqualität Wohnzimmer"
|
|
|
|
|
2021-09-28 12:04:54 +02:00
|
|
|
esphome:
|
2023-05-27 16:52:05 +02:00
|
|
|
name: ${name}
|
|
|
|
friendly_name: ${friendly_name}
|
|
|
|
name_add_mac_suffix: false
|
|
|
|
project:
|
|
|
|
name: sensor.${name}
|
|
|
|
version: "1.1"
|
|
|
|
min_version: 2021.9.0
|
|
|
|
|
2021-09-28 12:04:54 +02:00
|
|
|
on_boot:
|
|
|
|
then:
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 0%
|
|
|
|
green: 100%
|
|
|
|
blue: 9%
|
|
|
|
- delay: 1.5s
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 75%
|
|
|
|
blue: 0%
|
|
|
|
- delay: 1.5s
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 0%
|
|
|
|
blue: 0%
|
|
|
|
- delay: 1.5s
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 75%
|
|
|
|
blue: 0%
|
|
|
|
- delay: 1.5s
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 0%
|
|
|
|
green: 100%
|
|
|
|
blue: 9%
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "grün"
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: pm25_warn
|
|
|
|
state: "grün"
|
|
|
|
|
2023-05-27 16:52:05 +02:00
|
|
|
esp32:
|
|
|
|
board: nodemcu-32s
|
|
|
|
framework:
|
|
|
|
type: arduino
|
|
|
|
|
2021-09-28 12:04:54 +02:00
|
|
|
wifi:
|
|
|
|
ssid: "Voltage-legacy"
|
|
|
|
password: !secret voltage_legacy_psk
|
2023-05-27 16:52:05 +02:00
|
|
|
use_address: ${name}.home
|
2021-09-28 12:04:54 +02:00
|
|
|
power_save_mode: high
|
|
|
|
fast_connect: on
|
|
|
|
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
|
|
ap:
|
|
|
|
ssid: "Wohnzimmer Fallback Hotspot"
|
|
|
|
password: !secret fallback_psk
|
|
|
|
|
|
|
|
captive_portal:
|
|
|
|
|
|
|
|
# Enable logging
|
|
|
|
logger:
|
|
|
|
level: DEBUG
|
|
|
|
|
|
|
|
# Enable Home Assistant API
|
|
|
|
api:
|
2021-10-08 11:27:55 +02:00
|
|
|
encryption:
|
|
|
|
key: !secret apikey
|
2021-09-28 12:04:54 +02:00
|
|
|
|
|
|
|
# Enable over-the-air updates
|
|
|
|
ota:
|
|
|
|
password: !secret ota
|
|
|
|
|
|
|
|
# Initialize I²C
|
|
|
|
i2c:
|
|
|
|
- id: bus_a
|
2021-09-28 20:06:29 +02:00
|
|
|
sda: 32
|
|
|
|
scl: 25
|
2021-09-28 12:04:54 +02:00
|
|
|
scan: true
|
|
|
|
|
|
|
|
# Initialize LEDC GPIOs
|
|
|
|
output:
|
|
|
|
- platform: ledc
|
2021-09-28 20:06:29 +02:00
|
|
|
pin: GPIO16
|
2021-09-28 12:04:54 +02:00
|
|
|
id: led_red
|
|
|
|
- platform: ledc
|
2021-09-28 20:06:29 +02:00
|
|
|
pin: GPIO15
|
2021-09-28 12:04:54 +02:00
|
|
|
id: led_green
|
|
|
|
max_power: 50%
|
|
|
|
- platform: ledc
|
|
|
|
pin: GPIO19
|
|
|
|
id: led_blue
|
|
|
|
|
|
|
|
# Define RGB mode for LED
|
|
|
|
light:
|
|
|
|
- platform: rgb
|
|
|
|
id: co2_light
|
|
|
|
name: "CO2 Status LED"
|
|
|
|
red: led_red
|
|
|
|
green: led_green
|
|
|
|
blue: led_blue
|
|
|
|
internal: true
|
|
|
|
|
|
|
|
# Initialize UART for Vindriktning sensor
|
|
|
|
uart:
|
2021-09-28 20:06:29 +02:00
|
|
|
rx_pin: GPIO22
|
2021-09-28 12:04:54 +02:00
|
|
|
baud_rate: 9600
|
|
|
|
|
|
|
|
# Create text sensor to represent CO2 LED warn state (somewhat redundant)
|
|
|
|
text_sensor:
|
|
|
|
- platform: template
|
|
|
|
name: "Wohnzimmer CO2 Warnstufe"
|
|
|
|
id: co2_warn
|
|
|
|
- platform: template
|
|
|
|
name: "Wohnzimmer Feinstaub Warnstufe"
|
|
|
|
id: pm25_warn
|
|
|
|
|
|
|
|
sensor:
|
|
|
|
# WiFi signal strength
|
|
|
|
- platform: wifi_signal
|
|
|
|
name: "WiFi Signalstärke"
|
|
|
|
update_interval: 60s
|
|
|
|
# SCD30 CO2 + temperature + humidity sensor
|
|
|
|
# * air quality category 0: LED is purple, sensor needs calibration (<380ppm)
|
|
|
|
# • air quality category 1: LED is green (380-800ppm)
|
|
|
|
# • air quality category 2: LED is yellow (900-1200ppm)
|
|
|
|
# • air quality category 3: LED is orange/amber (1200 to 1600ppm)
|
|
|
|
# • air quality category 4: LED is red (1600-2000ppm)
|
|
|
|
- platform: scd30
|
|
|
|
i2c_id: bus_a
|
|
|
|
co2:
|
|
|
|
name: "Wohnzimmer CO2"
|
|
|
|
id: co2_value
|
|
|
|
accuracy_decimals: 1
|
|
|
|
on_value_range:
|
|
|
|
- below: 380
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "Kalibrierung nötig"
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 75%
|
|
|
|
green: 0%
|
|
|
|
blue: 100%
|
|
|
|
- above: 380
|
|
|
|
below: 800
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "grün"
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 0%
|
|
|
|
green: 100%
|
|
|
|
blue: 0%
|
|
|
|
- above: 800
|
|
|
|
below: 1200
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "gelb"
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 100%
|
|
|
|
blue: 0%
|
|
|
|
- above: 1200
|
|
|
|
below: 1600
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "orange"
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 75%
|
|
|
|
blue: 0%
|
|
|
|
- above: 1600
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "rot"
|
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 0%
|
|
|
|
blue: 0%
|
|
|
|
temperature:
|
|
|
|
name: "Wohnzimmer Temperatur"
|
|
|
|
accuracy_decimals: 2
|
|
|
|
humidity:
|
|
|
|
name: "Wohnzimmer Luftfeuchtigkeit"
|
|
|
|
accuracy_decimals: 1
|
|
|
|
# SCD30 temp sensor is a bit off
|
2021-09-30 08:12:12 +02:00
|
|
|
temperature_offset: 0 °C
|
2021-09-28 12:04:54 +02:00
|
|
|
ambient_pressure_compensation: 1
|
|
|
|
automatic_self_calibration: True
|
|
|
|
address: 0x61
|
|
|
|
update_interval: 60s
|
|
|
|
# Vindriktning particulate matter sensor
|
|
|
|
- platform: pm1006
|
|
|
|
pm_2_5:
|
|
|
|
name: "Wohnzimmer 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
|
|
|
|
- platform: adc
|
2021-09-28 20:06:29 +02:00
|
|
|
pin: 34
|
2021-09-28 12:04:54 +02:00
|
|
|
name: "Spannung Photodiode"
|
|
|
|
attenuation: 11db
|
|
|
|
update_interval: 1s
|
|
|
|
internal: true
|
|
|
|
on_value_range:
|
|
|
|
- below: 0.25
|
|
|
|
then:
|
|
|
|
light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
brightness: 30%
|
2021-10-08 11:27:55 +02:00
|
|
|
- above: 0.5
|
2021-09-28 12:04:54 +02:00
|
|
|
then:
|
|
|
|
light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
brightness: 60%
|