feat: add co2 sensor

This commit is contained in:
neri 2024-06-29 00:02:39 +02:00
parent 4b52e365e4
commit 2eff076d5b
2 changed files with 115 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea/
venv/
.esphome/

114
co2-sensor.yaml Normal file
View File

@ -0,0 +1,114 @@
esphome:
name: co2-sensor-raum3
friendly_name: "CO2 Sensor Raum 3"
area: "Raum 3"
on_boot:
- priority: -100
then:
- light.turn_on: {
id: co2_sensor_raum3_led,
red: 0%, green: 0%, blue: 100%
}
esp8266:
board: d1_mini
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
password: ""
services:
- service: calibrate
then:
- mhz19.calibrate_zero: co2_sensor_raum3_sensor
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "CO2 Sensor Raum 3 Fallback"
password: !secret ap_password
manual_ip:
static_ip: 172.23.23.31
gateway: 172.23.23.1
subnet: 255.255.255.0
captive_portal:
uart:
rx_pin: GPIO3
tx_pin: GPIO1
baud_rate: 9600
sensor:
- platform: mhz19
id: co2_sensor_raum3_sensor
co2:
id: co2_sensor_raum3_messwert
name: "Messwert"
on_value_range:
- below: 700
then:
- light.turn_on: {
id: co2_sensor_raum3_led,
red: 32%, green: 57%, blue: 12%,
effect: none
}
- above: 700
below: 1200
then:
- light.turn_on: {
id: co2_sensor_raum3_led,
red: 96%, green: 76%, blue: 6%,
effect: none
}
- above: 1200
below: 1500
then:
- light.turn_on: {
id: co2_sensor_raum3_led,
red: 100%, green: 12%, blue: 0%,
effect: none
}
- above: 1500
then:
- light.turn_on: {
id: co2_sensor_raum3_led,
red: 100%, green: 12%, blue: 0%,
effect: blink
}
temperature:
id: co2_sensor_raum3_temperatur
name: "Temperatur"
update_interval: 60s
automatic_baseline_calibration: false
light:
- platform: neopixelbus
id: co2_sensor_raum3_led
name: "LED"
type: GRB
variant: WS2812
pin: D2
num_leds: 7
effects:
- pulse:
name: blink
transition_length: 0s
update_interval: 1s
binary_sensor:
- platform: gpio
id: co2_sensor_raum3_button
name: "Button"
pin: D6