2021-08-24 13:08:35 +02:00
|
|
|
esphome:
|
|
|
|
name: sleepingroom
|
|
|
|
platform: ESP32
|
|
|
|
board: nodemcu-32s
|
|
|
|
|
2021-09-04 12:28:10 +02:00
|
|
|
# Startup animation
|
|
|
|
#on_boot:
|
|
|
|
# then:
|
|
|
|
|
|
|
|
#script:
|
|
|
|
# - id: startup_animation
|
2021-09-03 17:39:32 +02:00
|
|
|
# then:
|
2021-09-04 12:28:10 +02:00
|
|
|
# - delay: 5s
|
|
|
|
# -
|
2021-08-24 13:08:35 +02:00
|
|
|
|
|
|
|
wifi:
|
|
|
|
ssid: "Voltage-legacy"
|
|
|
|
password: !secret voltage_legacy_psk
|
|
|
|
use_address: sleepingroom.home
|
|
|
|
power_save_mode: high
|
|
|
|
fast_connect: on
|
|
|
|
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
|
|
ap:
|
|
|
|
ssid: "Schlafzimmer Fallback Hotspot"
|
|
|
|
password: !secret fallback_psk
|
|
|
|
|
|
|
|
captive_portal:
|
|
|
|
|
|
|
|
# Enable logging
|
|
|
|
logger:
|
|
|
|
|
|
|
|
# Enable Home Assistant API
|
|
|
|
api:
|
|
|
|
password: !secret api
|
|
|
|
|
|
|
|
# Enable over-the-air updates
|
|
|
|
ota:
|
|
|
|
password: !secret ota
|
|
|
|
|
|
|
|
# Initialize I²C
|
|
|
|
i2c:
|
|
|
|
- id: bus_a
|
|
|
|
sda: 13
|
|
|
|
scl: 16
|
|
|
|
scan: true
|
|
|
|
|
|
|
|
# Initialize LEDC GPIOs
|
|
|
|
output:
|
|
|
|
- platform: ledc
|
|
|
|
pin: GPIO17
|
|
|
|
id: led_red
|
|
|
|
- platform: ledc
|
|
|
|
pin: GPIO18
|
|
|
|
id: led_green
|
2021-09-03 17:39:32 +02:00
|
|
|
max_power: 50%
|
2021-09-02 22:05:19 +02:00
|
|
|
- platform: ledc
|
|
|
|
pin: GPIO19
|
|
|
|
id: led_blue
|
2021-08-24 13:08:35 +02:00
|
|
|
|
2021-09-04 12:28:10 +02:00
|
|
|
# Define RGB mode for LED
|
2021-09-03 17:39:32 +02:00
|
|
|
light:
|
|
|
|
- platform: rgb
|
|
|
|
id: co2_light
|
|
|
|
name: "CO2 Status LED"
|
|
|
|
red: led_red
|
|
|
|
green: led_green
|
|
|
|
blue: led_blue
|
2021-09-04 12:28:10 +02:00
|
|
|
internal: true
|
2021-09-03 17:39:32 +02:00
|
|
|
|
2021-08-28 19:36:14 +02:00
|
|
|
# Initialize UART for Vindriktning sensor
|
|
|
|
uart:
|
2021-09-03 08:27:18 +02:00
|
|
|
rx_pin: GPIO26
|
2021-08-28 19:36:14 +02:00
|
|
|
baud_rate: 9600
|
|
|
|
|
2021-08-24 13:08:35 +02:00
|
|
|
# Create text sensor to represent CO2 LED warn state (somewhat redundant)
|
|
|
|
text_sensor:
|
|
|
|
- platform: template
|
|
|
|
name: "Schlafzimmer CO2 Warnstufe"
|
|
|
|
id: co2_warn
|
2021-09-03 17:39:32 +02:00
|
|
|
- platform: template
|
|
|
|
name: "Schlafzimmer Feinstaub Warnstufe"
|
|
|
|
id: pm25_warn
|
2021-08-24 13:08:35 +02:00
|
|
|
|
|
|
|
sensor:
|
2021-09-03 08:27:18 +02:00
|
|
|
# WiFi signal strength
|
2021-08-24 13:08:35 +02:00
|
|
|
- platform: wifi_signal
|
|
|
|
name: "WiFi Signalstärke"
|
|
|
|
update_interval: 60s
|
2021-09-04 12:28:10 +02:00
|
|
|
# SCD30 CO2 + temperature + humidity sensor
|
|
|
|
# * air quality category 0: LED is purple, sensor needs calibration (<400ppm)
|
|
|
|
# • air quality category 1: LED is green (400-800ppm)
|
|
|
|
# • air quality category 2: LED is yellow (900-1200ppm)
|
|
|
|
# • air quality category 3: LED is orange/amber (1200 bis 1600ppm)
|
|
|
|
# • air quality category 4: LED is red (1600-2000ppm)
|
2021-08-24 13:08:35 +02:00
|
|
|
- platform: scd30
|
|
|
|
i2c_id: bus_a
|
|
|
|
co2:
|
|
|
|
name: "Schlafzimmer CO2"
|
|
|
|
id: co2_value
|
|
|
|
accuracy_decimals: 1
|
|
|
|
on_value_range:
|
2021-09-04 12:28:10 +02:00
|
|
|
- below: 400
|
|
|
|
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: 400
|
2021-08-24 13:08:35 +02:00
|
|
|
below: 800
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "grün"
|
2021-09-04 12:28:10 +02:00
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 0%
|
|
|
|
green: 100%
|
|
|
|
blue: 9%
|
2021-08-24 13:08:35 +02:00
|
|
|
- above: 800
|
|
|
|
below: 1200
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "gelb"
|
2021-09-04 12:28:10 +02:00
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 100%
|
|
|
|
blue: 0%
|
2021-08-24 13:08:35 +02:00
|
|
|
- above: 1200
|
|
|
|
below: 1600
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "orange"
|
2021-09-04 12:28:10 +02:00
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 75%
|
|
|
|
blue: 0%
|
2021-08-24 13:08:35 +02:00
|
|
|
- above: 1600
|
|
|
|
then:
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: co2_warn
|
|
|
|
state: "rot"
|
2021-09-04 12:28:10 +02:00
|
|
|
- light.turn_on:
|
|
|
|
id: co2_light
|
|
|
|
red: 100%
|
|
|
|
green: 0%
|
|
|
|
blue: 0%
|
2021-08-24 13:08:35 +02:00
|
|
|
temperature:
|
|
|
|
name: "Schlafzimmer Temperatur"
|
|
|
|
accuracy_decimals: 2
|
|
|
|
humidity:
|
|
|
|
name: "Schlafzimmer Luftfeuchtigkeit"
|
|
|
|
accuracy_decimals: 1
|
|
|
|
# SCD30 temp sensor is a bit off
|
|
|
|
temperature_offset: 1.5 °C
|
|
|
|
ambient_pressure_compensation: 1
|
|
|
|
automatic_self_calibration: True
|
|
|
|
address: 0x61
|
|
|
|
update_interval: 60s
|
|
|
|
- platform: bmp280
|
|
|
|
i2c_id: bus_a
|
|
|
|
temperature:
|
|
|
|
name: "Schlafzimmer Temperatur alt"
|
|
|
|
oversampling: 16x
|
|
|
|
pressure:
|
|
|
|
name: "Schlafzimmer Luftdruck"
|
|
|
|
address: 0x76
|
|
|
|
update_interval: 60s
|
2021-09-03 08:27:18 +02:00
|
|
|
# Vindriktning particulate matter sensor
|
2021-08-28 19:36:14 +02:00
|
|
|
- platform: pm1006
|
|
|
|
pm_2_5:
|
|
|
|
name: "Feinstaub PM 2.5µm"
|
2021-09-03 17:39:32 +02:00
|
|
|
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"
|
2021-09-03 08:27:18 +02:00
|
|
|
# Analog photo diode voltage
|
2021-09-02 22:05:19 +02:00
|
|
|
- platform: adc
|
|
|
|
pin: 32
|
|
|
|
name: "Spannung Photodiode"
|
|
|
|
attenuation: 11db
|
2021-09-03 08:27:18 +02:00
|
|
|
update_interval: 1s
|
|
|
|
internal: true
|
2021-09-03 17:39:32 +02:00
|
|
|
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%
|
2021-08-24 13:08:35 +02:00
|
|
|
|
2021-08-28 19:36:14 +02:00
|
|
|
# IR Receiver, dumps all received values into serial
|
2021-08-25 07:32:57 +02:00
|
|
|
remote_receiver:
|
|
|
|
pin:
|
|
|
|
number: 23
|
2021-08-28 19:36:14 +02:00
|
|
|
inverted: True
|
2021-08-25 07:32:57 +02:00
|
|
|
dump: all
|
|
|
|
|
2021-08-28 19:36:14 +02:00
|
|
|
# IR Transmitter
|
2021-08-25 07:32:57 +02:00
|
|
|
remote_transmitter:
|
|
|
|
pin: GPIO22
|
|
|
|
# Infrared remotes use a 50% carrier signal
|
|
|
|
carrier_duty_percent: 50%
|
|
|
|
|
2021-08-28 19:36:14 +02:00
|
|
|
# Temporary test switches
|
2021-08-25 07:32:57 +02:00
|
|
|
switch:
|
|
|
|
- platform: template
|
|
|
|
name: Yamaha Power Button
|
|
|
|
turn_on_action:
|
2021-08-28 19:36:14 +02:00
|
|
|
- remote_transmitter.transmit_nec:
|
|
|
|
address: 0x7E81
|
|
|
|
command: 0x54AB
|
2021-08-25 07:32:57 +02:00
|
|
|
- platform: template
|
|
|
|
name: Samsung Power Button
|
|
|
|
turn_on_action:
|
2021-08-28 19:36:14 +02:00
|
|
|
- remote_transmitter.transmit_samsung:
|
|
|
|
data: 0xE0E040BF
|
|
|
|
nbits: 32
|