-
Notifications
You must be signed in to change notification settings - Fork 0
/
vindriktning.yaml
289 lines (260 loc) · 7 KB
/
vindriktning.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# ESPHome MCU replacement for IKEA Vindriktning.
# Sensors
# - PM1006 PM2.5 particulate sensor (came with IKEA Vindriktning)
# - PM1006 fan soldered to 3V instead of 5V (quieter) and runs continuously (so don't have the start/stop sound)
# - SGP30 for TVOC and eCO2
# - BME280 for temparture, humidity, air pressure
# - WS2812B led strip of individually addressable RGB LEDs to replace the IKEA led strip on the front
esphome:
name: vindriktning
friendly_name: Vindriktning
on_boot:
priority: 600
then:
- uart.write:
# Initialise the PM1006 sensor on startup (need to cycle power to sensor as well, not just rest ESP)
id: ikea_pm1006
data: [0x11, 0x02, 0x0B, 0x01, 0xE1]
- light.turn_on:
id: status_light
brightness: 100%
red: 100%
green: 100%
blue: 100%
effect: "Scan"
esp8266:
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: 10.0.0.13
ap:
password: !secret fallback_password
power_save_mode: LIGHT
captive_portal:
logger:
logs:
#sensor: none
pm1006: none
#sgp30: none
api:
on_client_connected:
- light.turn_on:
id: status_light
red: 0%
green: 100%
blue: 0%
effect: "None"
ota:
i2c:
sda: D2
scl: D1
uart:
id: ikea_pm1006
baud_rate: 9600
tx_pin: D0
rx_pin: D5
sensor:
- platform: pm1006
update_interval: 20s
pm_2_5:
name: "2.5µm"
on_value:
then:
- lambda: |-
if (x < 10) {
id(pm25_health).publish_state(0);
} else if (x < 20) {
id(pm25_health).publish_state(1);
} else if (x < 25) {
id(pm25_health).publish_state(2);
} else if (x < 50) {
id(pm25_health).publish_state(3);
} else if (x < 75) {
id(pm25_health).publish_state(4);
} else {
id(pm25_health).publish_state(5);
}
- platform: sgp30
update_interval: 1s
eco2:
name: "eCO2"
accuracy_decimals: 1
filters:
- sliding_window_moving_average:
window_size: 20
send_every: 20
on_value:
then:
- lambda: |-
if (x < 450) {
id(eco2_health).publish_state(0);
} else if (x < 700) {
id(eco2_health).publish_state(1);
} else if (x < 1000) {
id(eco2_health).publish_state(2);
} else if (x < 2500) {
id(eco2_health).publish_state(3);
} else if (x < 5000) {
id(eco2_health).publish_state(4);
} else {
id(eco2_health).publish_state(5);
}
tvoc:
name: "TVOC"
accuracy_decimals: 1
filters:
- sliding_window_moving_average:
window_size: 20
send_every: 20
on_value:
then:
- lambda: |-
if (x < 65) {
id(tvoc_health).publish_state(0);
} else if (x < 220) {
id(tvoc_health).publish_state(1);
} else if (x < 660) {
id(tvoc_health).publish_state(2);
} else if (x < 2200) {
id(tvoc_health).publish_state(3);
} else if (x < 5500) {
id(tvoc_health).publish_state(4);
} else {
id(tvoc_health).publish_state(5);
}
compensation:
temperature_source: temperature
humidity_source: humidity
- platform: bme280
address: 0x76
update_interval: 60s
temperature:
name: "Temperature"
id: temperature
oversampling: 1x
filters:
- calibrate_linear:
method: least_squares
datapoints:
- 24.7 -> 21.2
- 16.3 -> 13.0
humidity:
name: "Humidity"
id: humidity
oversampling: 1x
filters:
- calibrate_linear:
method: least_squares
datapoints:
- 20.0 -> 31.0
- 27.3 -> 37.1
pressure:
name: "Pressure"
oversampling: 1x
- platform: wifi_signal
name: "WiFi signal"
- platform: uptime
name: "Uptime"
- platform: homeassistant
id: room_brightness
entity_id: light.bedside_lights
attribute: brightness
on_value:
then:
- light.turn_on:
id: status_light
brightness: !lambda |-
if (isnan(x)) {
return 0;
} else {
return x/255.0;
}
- platform: template
name: "2.5µm Health"
id: pm25_health
update_interval: 20s
on_value:
- script.execute: update_status_light
- platform: template
name: "eCO2 Health"
id: eco2_health
update_interval: 20s
on_value:
- script.execute: update_status_light
- platform: template
name: "TVOC Health"
id: tvoc_health
update_interval: 20s
on_value:
- script.execute: update_status_light
light:
- platform: neopixelbus
id: status_light
name: Status
type: GRB
variant: WS2812
pin: D3
num_leds: 6
effects:
- addressable_rainbow:
- addressable_color_wipe:
- addressable_scan:
- addressable_twinkle:
- addressable_fireworks:
- addressable_flicker:
switch:
- platform: restart
name: "Restart"
script:
- id: update_status_light
then:
- lambda: |-
auto light = id(status_light).make_call();
light.set_transition_length(3000);
uint8_t health = max(id(pm25_health).state, max(id(eco2_health).state, id(tvoc_health).state));
//ESP_LOGD("update_status_light", "eCO2 %i, TVOC %i -> max %i", id(eco2_health).state, id(tvoc_health).state, health);
switch (health) {
case 0:
light.set_rgb(0, 1, 0); // dark green
break;
case 1:
light.set_rgb(0.5, 1, 0); // lighter green
break;
case 2:
light.set_rgb(1, 1, 0); // yellow
break;
case 3:
light.set_rgb(1, 0.6, 0); // orange
break;
case 4:
light.set_rgb(1, 0, 0); // red
break;
default:
light.set_rgb(1, 0, 0.8); // deep red
}
light.perform();
# Colour bands
# CO2
# < 450 Outdoor quality (dark green)
# < 700 Good (green)
# < 1000 Stuffy, acceptable (yellow)
# < 2500 Drowsiness (orange)
# < 5000 Adverse health effects (red)
# > 5000 Limit to max 8 hours (alert)
# TVOC
# < 65 Excellent (dark green)
# < 220 Good (green)
# < 660 Moderate (yellow)
# < 2200 Poor (orange)
# < 5500 Unhealthy (red)
# > 5500 (alert)
# PM2.5 – https://airindex.eea.europa.eu/Map/AQI/Viewer/
# < 10 Good
# < 20 Fair
# < 25 Moderate
# < 50 Poor
# < 75 Very poor
# > 800 Extremley poor
# 2 Jan
# Current eCO2 baseline: 0x9008, TVOC baseline: 0x9CCF