-
Notifications
You must be signed in to change notification settings - Fork 1
/
aerogarden.yaml
356 lines (323 loc) · 10.6 KB
/
aerogarden.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
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
substitutions:
devicename: "aerogarden"
upper_devicename: "AeroGarden"
esphome:
name: ${devicename}
includes:
- esphome-mlx90614-i2c_IR_temp_sensor/custom/mlx90614.h
- esphome-customisations/vl6180x/vl6180x_sensor.h
libraries:
- Wire
- SPI
- https://github.com/adafruit/Adafruit_BusIO.git
- https://github.com/adafruit/Adafruit-MLX90614-Library.git
- https://github.com/adafruit/Adafruit_VL6180X.git
esp32:
board: m5stick-c
framework:
type: arduino
external_components:
- source: github://airy10/esphome-m5stickC
components: [ axp192 ]
logger:
level: INFO
api:
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: $devicename Fallback Hotspot
password: !secret wifi_password
light:
- platform: status_led
name: ${upper_devicename} LED
id: plant_food_light
restore_mode: ALWAYS_OFF
pin:
number: GPIO10
inverted: true
spi:
clk_pin: GPIO13
mosi_pin: GPIO15
i2c:
- id: bus_a
sda: GPIO32
scl: GPIO33
scan: true
frequency: 50kHz
- id: bus_b
sda: GPIO21
scl: GPIO22
scan: true
button:
- platform: restart
name: ${upper_devicename} Restart
entity_category: diagnostic
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: ${upper_devicename} Firmware Version
id: esphome_version
entity_category: diagnostic
interval:
- interval: 30s
then:
- if:
condition:
and:
- wifi.connected:
- lambda: 'return (id(water_distance).state > 85) || ((id(homeassistant_time).now().timestamp - id(plant_food_timestamp)) > (14 * 86400));'
then:
- light.turn_on:
id: plant_food_light
- interval: 6s
then:
- if:
condition:
wifi.connected:
then:
- display.page.show_next: display1
- if:
condition:
display.is_displaying_page: page_startup
then:
- display.page.show_next: display1
- component.update: display1
else:
- display.page.show: page_startup
- component.update: display1
display:
- platform: st7789v
model: TTGO TDisplay 135x240
cs_pin: GPIO5
dc_pin: GPIO23
reset_pin: GPIO18
rotation: 90
id: display1
pages:
- id: page_startup
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), white, TextAlign::CENTER, "Connecting");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_14), white, TextAlign::CENTER, id(esphome_version).state.c_str());
- id: page_time
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Time");
it.strftime(it.get_width()/2, it.get_height()/2 + 8, id(roboto_54), TextAlign::CENTER, "%H:%M", id(homeassistant_time).now());
it.strftime(it.get_width()/2, it.get_height()/2 + 52, id(roboto_32), TextAlign::CENTER, "%m/%d/%Y", id(homeassistant_time).now());
- id: page_air_temp
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Air Temp.");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f °F", id(air_temp).state * (9.0/5.0) + 32.0);
- id: page_air_pressure
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Air Pressure");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f hPa", id(air_pressure).state);
- id: page_humidity
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Humidity");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f %%", id(humidity).state);
- id: page_water_temp
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Water Temp.");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f °F", id(water_temp).state * (9.0/5.0) + 32.0);
- id: page_water_level
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Water Level");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f %%", id(water_level).state);
- id: page_eco2
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "Carbon Dioxide");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f ppm", id(eco2).state);
- id: page_tvoc
lambda: |-
auto red = Color(255, 0, 0);
auto white = Color(255, 255, 255);
it.rectangle(0,0,it.get_width(),49,white);
it.filled_rectangle(1,1,it.get_width()-1,48,red);
it.print(it.get_width()/2, 25, id(roboto_32), TextAlign::CENTER, "TVOC");
it.printf(it.get_width()/2, it.get_height()/2 + 24, id(roboto_54), TextAlign::CENTER, "%.0f ppb", id(tvoc).state);
font:
- file: "gfonts://Roboto"
id: roboto_14
size: 14
- file: "gfonts://Roboto"
id: roboto_32
size: 32
- file: "gfonts://Roboto"
id: roboto_54
size: 54
globals:
- id: plant_food_timestamp
type: time_t
restore_value: yes
initial_value: '0'
binary_sensor:
- platform: gpio
pin:
number: GPIO37
inverted: true
id: button_a
on_press:
then:
- sensor.template.publish:
id: plant_food_added
state: !lambda 'id(plant_food_timestamp) = id(homeassistant_time).now().timestamp; return id(plant_food_timestamp);'
- light.turn_off:
id: plant_food_light
- platform: gpio
pin:
number: GPIO39
inverted: true
id: button_b
sensor:
- platform: template
name: ${upper_devicename} Water Level
id: water_level
lambda: |-
if (id(water_distance).state != NAN) {
float distance = id(water_distance).state - 40;
if (distance < 0)
distance = 0;
if (distance > 60)
distance = 60;
return 100.0f - (distance / 60.0f * 100.0f);
} else {
return {};
}
update_interval: 60s
unit_of_measurement: "%"
accuracy_decimals: 0
- platform: template
name: ${upper_devicename} Plant Food Added
device_class: timestamp
id: plant_food_added
lambda: !lambda 'if (id(plant_food_timestamp) != 0) {return id(plant_food_timestamp); } else {return {}; } ;'
- platform: homeassistant
id: brightness
entity_id: input_number.aerogarden_lcd_brightness
internal: true
on_value:
then:
lambda: |-
id(backlight).set_brightness(id(brightness).state/100.0);
id(backlight).update();
- platform: custom
lambda: |-
auto mlx = new MLX90614(30000);
App.register_component(mlx);
return {mlx->object_temperature_sensor};
sensors:
- name: ${upper_devicename} Water Temperature
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 1
id: water_temp
- platform: custom
lambda: |-
auto vl6180x_sensor = new VL6180XSensor();
App.register_component(vl6180x_sensor);
return {vl6180x_sensor->distance_sensor};
sensors:
- name: ${upper_devicename} Water Distance
id: water_distance
unit_of_measurement: mm
device_class: distance
accuracy_decimals: 0
- platform: wifi_signal
name: ${upper_devicename} WiFi Signal
entity_category: diagnostic
- platform: uptime
name: ${upper_devicename} Uptime
entity_category: diagnostic
- platform: axp192
address: 0x34
i2c_id: bus_b
id: backlight
battery_level:
name: ${upper_devicename} Battery Level
brightness: 0.5
- platform: sht3xd
i2c_id: bus_a
temperature:
name: ${upper_devicename} Temperature
id: air_temp
filters:
- filter_out: nan
- throttle_average: 60s
humidity:
name: ${upper_devicename} Humidity
id: humidity
filters:
- filter_out: nan
- throttle_average: 60s
update_interval: 1s
- platform: qmp6988
i2c_id: bus_a
pressure:
name: ${upper_devicename} Air Pressure
oversampling: 16x
id: air_pressure
filters:
- filter_out: nan
- throttle_average: 60s
iir_filter: 2x
update_interval: 1s
- platform: sgp30
i2c_id: bus_a
eco2:
name: ${upper_devicename} eCO2
accuracy_decimals: 1
id: eco2
filters:
- filter_out: nan
- throttle_average: 60s
tvoc:
name: ${upper_devicename} TVOC
accuracy_decimals: 1
id: tvoc
filters:
- filter_out: nan
- throttle_average: 60s
store_baseline: yes
update_interval: 1s
compensation:
temperature_source: air_temp
humidity_source: humidity