-
Notifications
You must be signed in to change notification settings - Fork 5
/
epaper-display.yaml
297 lines (249 loc) · 9.96 KB
/
epaper-display.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
esphome:
name: epaper-display
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "your_password"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Epaper-Display Fallback Hotspot"
password: "fallback_password"
captive_portal:
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
font:
- file: 'fonts/Roboto-Medium.ttf'
id: roboto_med_30
size: 30
- file: 'fonts/Roboto-Regular.ttf'
id: footer_font
size: 15
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']
- file: 'fonts/Roboto-Regular.ttf'
id: main_sensor_unit
size: 20
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']
- file: 'fonts/Roboto-Medium.ttf'
id: sub_sensor_font
size: 30
glyphs:
['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']
- file: 'fonts/Roboto-Bold.ttf'
id: main_sensor_font
size: 72
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_small
size: 31
glyphs: [
# Wifi
'', # mdi-wifi-strength-alert-outline
'', # mdi-wifi-strength-1
'', # mdi-wifi-strength-2
'', # mdi-wifi-strength-3
'', # mdi-wifi-strength-4
'', # mdi-themometer
'', # mdi-water-percent
'', # mdi-sun
'', # mdi-plant
'' # mdi-water-can
]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_wifi
size: 20
glyphs: [
# Wifi
'', # mdi-wifi-strength-alert-outline
'', # mdi-wifi-strength-1
'', # mdi-wifi-strength-2
'', # mdi-wifi-strength-3
'' # mdi-wifi-strength-4
]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_med
size: 33
glyphs: [
# Wifi
'', # mdi-wifi-strength-alert-outline
'', # mdi-wifi-strength-1
'', # mdi-wifi-strength-2
'', # mdi-wifi-strength-3
'', # mdi-wifi-strength-4
'' # mdi-alert
]
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: homeassistant
entity_id: sensor.indoor_co2
id: air_quality
- platform: homeassistant
entity_id: sensor.indoor_temp
id: temp_indoor
- platform: homeassistant
entity_id: sensor.indoor_humid
id: humid_indoor
- platform: homeassistant
entity_id: sensor.basement_humid
id: basement_humid
- platform: homeassistant
entity_id: sensor.basement_temp
id: basement_temp
- platform: homeassistant
entity_id: sensor.plant_temp
id: plant_temp
- platform: homeassistant
entity_id: sensor.plant_moisture
id: plant_moisture
- platform: homeassistant
entity_id: sensor.plant_illuminance
id: plant_illuminance
- platform: homeassistant
entity_id: sensor.plant_soil
id: plant_soil
- platform: wifi_signal
name: "WiFi Signal Sensor"
id: wifisignal
update_interval: 60s
display:
- platform: waveshare_epaper
cs_pin: GPIO26
dc_pin: GPIO25
busy_pin: GPIO27
reset_pin: GPIO33
model: 4.20in
rotation: 180
update_interval: 15min
id: epaperdisplay
lambda: |-
int offsetY = 137;
int air_quality_danger_thresh = 800;
int quality_air = int(id(air_quality).state);
float indoor_temp = id(temp_indoor).state;
float temp_plant = id(plant_temp).state;
float temp_basement = id(basement_temp).state;
int indoor_humid = int(id(humid_indoor).state);
int humid_basement = int(id(basement_humid).state);
int moisture_plant = int(id(plant_moisture).state);
int soil_plant = int(id(plant_soil).state);
int illuminance_plant = int(id(plant_illuminance).state);
/* OFFICE */
it.print(10, 10, id(main_sensor_unit), "OFFICE");
it.filled_rectangle(98, 21, 285, 3);
it.print(25, 114, id(main_sensor_unit), TextAlign::BASELINE_LEFT, "Co2");
it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //thermometer
it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //water-percent
if(indoor_temp > -100 && indoor_temp < 100){
it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%2.1fºc", indoor_temp);
}else{
it.print(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - ºc");
}
if(indoor_humid >=0 && indoor_humid <= 100){
it.printf(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%3d%%", indoor_humid);
}else{
it.print(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - %");
}
if(quality_air < 6000 && quality_air >=0){
if (quality_air > 100){
it.printf(230, 115, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%3d", quality_air);
it.print(230, 115, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "ppm");
}else{
it.printf(230, 115, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%2d", quality_air);
it.print(230, 115, id(main_sensor_unit), TextAlign::BASELINE_LEFT, "ppm");
}
if(quality_air >= air_quality_danger_thresh){
it.print(37, 87, id(mdi_med), TextAlign::BASELINE_CENTER, ""); //warning
}
}
else{
it.print(175, 114 + offsetY, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "- ");
it.print(180, 114 + offsetY, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "ppm");
}
/* PLANT */
it.print(10, 10 + offsetY, id(main_sensor_unit), "PLANT");
it.filled_rectangle(98, 21 + offsetY, 285, 3);
it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //thermometer
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //water-percent
it.print(230, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //watering-can
it.print(125, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //luminosity
it.print(230, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); //soil
if(temp_plant > -100 && temp_plant < 100){
it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%2.1fºc", temp_plant);
}else{
it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - ºc");
}
if(humid_basement >=0 && humid_basement <= 100){
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%3d%%", humid_basement);
}else{
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - %");
}
if(moisture_plant >=0 && moisture_plant <= 100){
it.printf(212, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%3d%%", moisture_plant);
}else{
it.print(212, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - %");
}
if(soil_plant >=0 && soil_plant <= 10000){
it.printf(212, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%3dµS/cm", soil_plant);
}else{
it.print(212, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - µS/cm");
}
if(illuminance_plant >=0 && illuminance_plant <= 30000){
it.printf(107, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , "%5d", illuminance_plant);
}else{
it.print(107, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT , " - lux");
}
/* FOOTERT */
it.strftime(355, 295 , id(footer_font), TextAlign::BASELINE_RIGHT , "Updated at %d/%b/%Y %H:%M", id(homeassistant_time).now());
/* WiFi Signal Strenght */
if(id(wifisignal).has_state()) {
int x = 375;
int y = 295;
if (id(wifisignal).state >= -50) {
//Excellent
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
ESP_LOGI("WiFi", "Exellent");
} else if (id(wifisignal).state >= -60) {
//Good
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
ESP_LOGI("WiFi", "Good");
} else if (id(wifisignal).state >= -75) {
//Fair
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
ESP_LOGI("WiFi", "Fair");
} else if (id(wifisignal).state >= -100) {
//Weak
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
ESP_LOGI("WiFi", "Weak");
} else {
//Unlikely working signal
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
ESP_LOGI("WiFi", "Unlikely");
}
}