-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrack.yaml
More file actions
395 lines (368 loc) · 8.62 KB
/
rack.yaml
File metadata and controls
395 lines (368 loc) · 8.62 KB
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
substitutions:
devicename: rack
devicename_upper: Rack
$friendly_name: Rack
<<: !include ./.base.yaml
## RECEIVE kp,ki and kd parameters from input_text.kx helpers in
# Home Assistant. See the PID controller below
# These helper values will get saved to flash thus permanently over-riding
# the initial values set in the PID below.
number:
# KP
- platform: template
name: kp
icon: mdi:chart-bell-curve
restore_value: true
min_value: 0
max_value: 50
step: 0.001
set_action:
lambda: |-
// ESP_LOGI("main", "!!!!!! kp from boot %d", id("rack_fan_kp") );
// id(rack_thermostat).set_kp( id("$friendly_name kp") );
id(rack_thermostat).set_kp( x );
# KI
- platform: template
name: ki
icon: mdi:chart-bell-curve
restore_value: true
min_value: 0
max_value: 50
step: 0.0001
set_action:
lambda: id(rack_thermostat).set_ki( x );
# KD
- platform: template
name: kd
icon: mdi:chart-bell-curve
restore_value: true
min_value: -50
max_value: 50
step: 0.001
set_action:
lambda: id(rack_thermostat).set_kd( x );
## Fan Output (PWM)
output:
- platform: esp8266_pwm
pin: D3
frequency: 25000Hz
id: fan_output
# ## Fan
fan:
- platform: speed
output: fan_output
name: Fan Speed
id: "${devicename}_fan"
speed_count: 100
## LED
light:
- platform: neopixelbus
type: GRBW
variant: WS2812
pin: GPIO3
num_leds: 30
name: Strip
id: strip
effects:
- pulse:
transition_length:
on_length: 1s
off_length: 500ms
update_interval: 1s
min_brightness: 15%
max_brightness: 70%
- addressable_scan:
scan_width: 5
- addressable_rainbow:
- addressable_color_wipe:
name: Police
colors:
- red: 100%
green: 0%
blue: 0%
white: 0%
num_leds: 5
- red: 0%
green: 0%
blue: 100%
white: 0%
num_leds: 5
- addressable_twinkle:
twinkle_probability: 10%
progress_interval: 20ms
- addressable_random_twinkle:
name: Random Twinkle
twinkle_probability: 10%
progress_interval: 20ms
- platform: partition
id: strip_right
segments:
- id: strip
from: 0
to: 14
effects:
- addressable_scan:
move_interval: 3s
- platform: partition
id: strip_left
segments:
- id: strip
from: 15
to: 29
reversed: true
effects:
- addressable_scan:
move_interval: 3s
## I2C
i2c:
sda: 4
scl: 5
scan: false
bme680_bsec:
address: 0x77
temperature_offset: 4
sample_rate: ulp
sensor:
## BME680
- platform: bme680_bsec
temperature:
id: bme680_temp
name: Temperature
sample_rate: lp
accuracy_decimals: 1
filters:
- median
on_value_range:
- below: 26
then:
- script.execute: led_blue
- above: 26
below: 30
then:
- script.execute: led_green
- above: 30
then:
- script.execute: led_red
pressure:
name: Pressure
sample_rate: lp
accuracy_decimals: 2
filters:
- median
humidity:
name: Humidity
sample_rate: lp
accuracy_decimals: 1
filters:
- median
iaq:
id: iaq
## Fan speed
- platform: pulse_counter
pin: D4
name: Fan RPM
update_interval: 10s
unit_of_measurement: rpm
accuracy_decimals: 0
icon: "mdi:fan"
filters:
- multiply: 0.5
# Take the "COOL" value of the pid and send
# it to the frontend to graph the output voltage
- platform: pid
id: fan_voltage
climate_id: rack_thermostat
type: COOL
########################################################
# START THE FAN CONTROLLER SETUP
- platform: template
name: p term
id: p_term
unit_of_measurement: "%"
accuracy_decimals: 2
- platform: template
name: i term
id: i_term
unit_of_measurement: "%"
accuracy_decimals: 2
- platform: template
name: d term
id: d_term
unit_of_measurement: "%"
accuracy_decimals: 2
- platform: template
name: output value
unit_of_measurement: "%"
id: o_term
accuracy_decimals: 2
- platform: template
name: error value
id: e_term
accuracy_decimals: 2
- platform: template
name: zero
id: zero_value
update_interval: 60s
lambda: |-
return 0;
- platform: template
name: zero percent
unit_of_measurement: "%"
id: zero_value_percent
update_interval: 60s
lambda: |-
return 0;
text_sensor:
- platform: template
name: "IAQ Classification"
icon: "mdi:checkbox-marked-circle-outline"
lambda: |-
if (int(id(iaq).state) <= 50) {
return {"Excellent"};
}
else if (int(id(iaq).state) <= 100) {
return {"Good"};
}
else if (int(id(iaq).state) <= 150) {
return {"Lightly polluted"};
}
else if (int(id(iaq).state) <= 200) {
return {"Moderately polluted"};
}
else if (int(id(iaq).state) <= 250) {
return {"Heavily polluted"};
}
else if (int(id(iaq).state) <= 350) {
return {"Severely polluted"};
}
else if (int(id(iaq).state) <= 500) {
return {"Extremely polluted"};
}
else {
return {"unknown"};
}
# Expose a PID-controlled Thermostat
# Manual: https://esphome.io/components/climate/pid.html
climate:
- platform: pid
name: Thermostat
id: rack_thermostat
sensor: bme680_temp
# It is summer right now, so 30c is a decent target.
default_target_temperature: 28°C
cool_output: fan_output
on_state:
- sensor.template.publish:
id: p_term
state: !lambda "return -id(rack_thermostat).get_proportional_term() * 100.0;"
- sensor.template.publish:
id: i_term
state: !lambda "return -id(rack_thermostat).get_integral_term()* 100.0;"
- sensor.template.publish:
id: d_term
state: !lambda "return -id(rack_thermostat).get_derivative_term()* 100.0;"
- sensor.template.publish:
id: o_term
state: !lambda "return -id(rack_thermostat).get_output_value()* 100.0;"
- sensor.template.publish:
id: e_term
state: !lambda "return -id(rack_thermostat).get_error_value();"
# dummy heater. enable this if using autotune
# heat_output: rack_heat_speed
# The extents of the HA Thermostat
visual:
min_temperature: 20 °C
max_temperature: 40 °C
# See the README for setting up these parameters.
# These are over ridden by the number templates above.
control_parameters:
kp: 0.15
ki: 0.004
kd: 0.5
max_integral: 0.0
## Automations
script:
## LED
# - id: led_pulsate
# then:
# - light.turn_on:
# id: strip
# red: 1
# blue: 1
# green: 0
# white: 0
# effect: pulse
- id: led_blue
then:
- light.turn_off: strip
- light.turn_on:
id: strip_left
red: 0
blue: 1
green: 0
white: 0
effect: Scan
brightness: .6
- light.turn_on:
id: strip_right
red: 0
blue: 1
green: 0
white: 0
effect: Scan
brightness: .6
- id: led_green
then:
- light.turn_off: strip
- light.turn_on:
id: strip_left
red: 0
blue: 0
green: 1
white: 0
effect: Scan
brightness: .6
- light.turn_on:
id: strip_right
red: 0
blue: 0
green: 1
white: 0
effect: Scan
brightness: .6
- id: led_red
then:
- light.turn_off: strip_left
- light.turn_off: strip_right
- light.turn_on:
id: strip
red: 1
blue: 0
green: 0
white: 0
effect: Pulse
brightness: .6
- id: led_pink
then:
- light.turn_off: strip_left
- light.turn_off: strip_right
- light.turn_on:
id: strip
red: 1
blue: 1
green: 0
white: 0
effect: Pulse
brightness: .6
- id: led_yellow
then:
- light.turn_off: strip_left
- light.turn_off: strip_right
- light.turn_on:
id: strip
red: 1
blue: 0
green: 1
white: 0
effect: Pulse
brightness: .6