/
ikea_aq_v2.yaml
133 lines (120 loc) · 3.35 KB
/
ikea_aq_v2.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
substitutions:
name: xxxxxxxxx ## Location & Entity Names (Capitals and Spaces Allowed)
ap_id: xxxxxxxxxx ## Entity ID for the Fan (E.G. IKEA Air Filter)
auto_enable: xxxxxxxxxxx ## Home Assistant Entity to Enable Automation
af_speeds: '6' ## Fan Speeds [MUST BE IN QUOTES]
pms_low: '40' ## 2.5µm Count for Fan Off [MUST BE IN QUOTES]
pms_high: '400' ## 2.5µm Count for Fan MAX [MUST BE IN QUOTES]
esphome:
name: studio-air-quality
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
ota:
logger:
logs:
sensor: none
binary_sensor: none
homeassistant.binary_sensor: none
pm1006: none
ccs811: none
## Serial Port for the IKEA Sensor
uart:
- rx_pin: D7
# tx_pin: D8
baud_rate: 9600
i2c:
## I²C Port - For Temp/Humidity/Pressure & CO²/VOC Sensors
sda: D1
scl: D2
scan: true
id: bus_a
binary_sensor:
## Reads On/Off State from HA
- platform: homeassistant
entity_id: $auto_enable
id: enable_automation
## Use the on-board LED to show "Fan Running"
- platform: gpio
name: $name Fan
id: fan
pin:
number: D4
inverted: true
## Brightness Sensor for HA Automations
- platform: template
name: $name Bright
id: bright
sensor:
## IKEA PMS 2.5µg Sensor
- platform: pm1006
id: aq_sensor
pm_2_5:
name: $name 2.5µg
on_value:
- if:
condition:
- binary_sensor.is_off: enable_automation
then:
- homeassistant.service:
service: number.set_value
data:
entity_id: $ap_id
value: !lambda |-
auto range = (x - $pms_low) / ($pms_high - $pms_low) * $af_speeds;
auto value = (x < $pms_low) ? 0 : (range > $af_speeds) ? $af_speeds : range;
return ceil(value);
else:
# If the "$auto_enable" binary sensor is on, set the fan speed to 0
- homeassistant.service:
service: number.set_value
data:
entity_id: $ap_id
value: '0'
## CO²/VOC Sensor
- platform: ccs811
eco2:
name: $name CO²
accuracy_decimals: 0
tvoc:
name: $name T-VOC
accuracy_decimals: 0
address: 0x5A
update_interval: 10s
temperature: bme_temp
humidity: bme_humi
## After Calibration, Uncomment and change "baseline:"
baseline: xxxxxx
## Temp/Humidity/Pressure Sensor
- platform: bme280_i2c
temperature:
name: $name Temperature
id: bme_temp
oversampling: 4x
humidity:
name: $name Humidity
id: bme_humi
oversampling: 4x
pressure:
name: $name Pressure
id: bme_press
oversampling: 4x
iir_filter: 16x
address: 0x76
update_interval: 10s
## The IKEA Light Level Sensor
- platform: adc
id: light_sensor
pin: A0
update_interval: 1s
## Check the value and turn On/Off our Binary Sensor
on_value:
- lambda: !lambda |
if (x > 0.01) {
id(bright).publish_state(true);
} else {
id(bright).publish_state(false);
}