-
Notifications
You must be signed in to change notification settings - Fork 4
/
co2sensor.yaml
178 lines (156 loc) · 4.06 KB
/
co2sensor.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
esphome:
name: ttgodisplay
platform: ESP32
board: esp32dev
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "somepassword"
ota:
password: "somepassword"
wifi:
ssid: "yourwifissid"
password: "yourwifipassword"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Co2Sensor fallback Hotspot"
password: "somepassword"
i2c:
id: bus_a
sda: GPIO21
scl: GPIO22
scan: True
sensor:
- platform: scd30
address: 0x61
i2c_id: bus_a
automatic_self_calibration: true
co2:
name: "CO2"
id: "co2data"
accuracy_decimals: 1
temperature:
name: "Temperature CO2"
id: "co2temp"
accuracy_decimals: 1
humidity:
name: "Humidity CO2"
id: "co2humid"
accuracy_decimals: 1
update_interval: 2s
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_gray
red: 50%
green: 50%
blue: 50%
font:
- file: "Helvetica.ttf"
id: helvetica_46
size: 46
- file: "Helvetica.ttf"
id: helvetica_24
size: 24
- file: "Helvetica.ttf"
id: helvetica_12
size: 12
- file: "Helvetica.ttf"
id: helvetica_8
size: 8
binary_sensor:
- platform: status
name: "Node Status"
id: system_status
- platform: gpio
pin:
number: GPIO0
inverted: true
mode: INPUT_PULLUP
name: "T-Display Button Input 0"
id: tdisplay_button_input_0
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "T-Display Button Input 1"
id: tdisplay_button_input_1
# We can still control the backlight independently from HomeAssistant
switch:
- platform: gpio
pin: GPIO4
name: "Backlight"
id: backlight
image:
- file: "image.png"
id: my_image
resize: 90x90
type: RGB24
- file: "moderate.png"
id: face_moderate
resize: 90x90
type: RGB24
- file: "poor.png"
id: face_poor
resize: 90x90
type: RGB24
time:
- platform: homeassistant
id: esptime
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 270
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
//To Display Date comment out the line and set corrdinates
// time it.strftime((240 / 2), (140 / 4) * 1 + 5, id(helvetica_24), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now())
//Live data output
it.printf(212, 33, id(helvetica_46), id(my_green), TextAlign::TOP_RIGHT, "%0.0f", id(co2data).state);
it.printf(130,95, id(helvetica_12), id(my_yellow), TextAlign::TOP_LEFT, "%0.1f°C", id(co2temp).state);
it.printf(194,95, id(helvetica_12), id(my_blue), TextAlign::TOP_LEFT, "%0.1f%%", id(co2humid).state);
//Static Stuff
it.print(5, 5, id(helvetica_12), id(my_yellow), TextAlign::TOP_LEFT, "CO2 Monitor");
it.print(215, 65, id(helvetica_12), id(my_green), TextAlign::TOP_LEFT, "ppm");
it.print(130, 112, id(helvetica_12), id(my_yellow), TextAlign::TOP_LEFT, "Temp");
it.print(194, 112, id(helvetica_12), id(my_blue), TextAlign::TOP_LEFT, "RH");
// Image display (Three Faces Set at co2 Thresholds <1100ppm, <1500pm )
if (id(co2data).state <1100) {
it.image(10, 35, id(face_good));
}
else if (id(co2data).state <1500) {
it.image(10, 35, id(face_moderate));
}
else {
it.image(10, 35, id(face_poor));
}
//Condional Text Display
if (id(system_status).state) {
it.print(235, 5, id(helvetica_12), id(my_green), TextAlign::TOP_RIGHT, "Online");
}
else {
it.print(235, 5, id(helvetica_12), id(my_red), TextAlign::TOP_RIGHT, "Offline");
}
captive_portal: