-
Notifications
You must be signed in to change notification settings - Fork 0
/
air-quality-d1.yaml
69 lines (59 loc) · 1.57 KB
/
air-quality-d1.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
esphome:
name: air-quality-d1
esp8266:
board: d1
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Air-Quality-D1 Fallback Hotspot"
password: "WpY0RQn3vKNO"
captive_portal:
uart:
rx_pin: GPIO4
baud_rate: 9600
text_sensor:
- platform: template
name: "Particulate Matter Level"
id: pm_level
sensor:
- platform: pm1006
pm_2_5:
id: pm_internal
internal: true
name: "Particulate Matter 2.5µm Concentration Internal"
filters:
- throttle: 1s
on_value:
then:
lambda: |-
id(particulate_matter_2_5um_concentration).publish_state(x);
- platform: template
id: particulate_matter_2_5um_concentration
name: "Particulate Matter 2.5µm Concentration"
unit_of_measurement: "µm"
device_class: pm25
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 20
on_value:
then:
lambda: |-
if(x < 45) {
if(id(pm_level).state != "low") {
id(pm_level).publish_state("low");
}
} else if(x < 75) {
if(id(pm_level).state != "med") {
id(pm_level).publish_state("med");
}
} else if(id(pm_level).state != "high") {
id(pm_level).publish_state("high");
}