This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
forked from MallocArray/airgradient_esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
airgradient.yml
189 lines (170 loc) · 5.72 KB
/
airgradient.yml
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
#=============================================================================
# LongDono/AirGradient-HomeAssistant
# You will need fonts in fonts/ from https://dejavu-fonts.github.io
#
# For help with ESPHome add-on setup in Home Assistant:
# https://esphome.io/guides/getting_started_hassio.html
#==[Configuration]============================================================
substitutions:
code_name: airgradient-lower # ex. airgradient-lower for a unit on lower level of home
nice_name: "AG Lower" # ex. "AG Lower" for display in Home Assistant
comment: "Lower Level AirGradient Air Quality Unit"
# co2_available: "true" # Set to false if SenseAir CO2 sensor not present
display_update: "3s" # How often to update the display, default 3s
#=============================================================================
esphome:
name: ${code_name}
comment: ${comment}
esp8266:
board: d1_mini
# Enable logging
logger:
level: debug
# Enable the Home Assistant API
api:
# Enable wireless ESPHome updates
ota:
password: ""
# Set clock with Home Assistant
time:
- platform: homeassistant
# WiFi Configuration
# https://esphome.io/components/wifi.html
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case WiFi connection fails
ap:
ssid: "${nice_name} Fallback"
# Password is optional
# password: "ix7tPFTuFDdV"
captive_portal:
# Configuration for AirGradient DIY v2 device
# https://www.esphome-devices.com/devices/AirGradient-DIY/
# https://esphome.io/components/uart.html#uart
uart:
# SenseAir CO2 Sensor Configuration
# Comment out this section if SenseAir CO2 Sensor is not present
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: senseair_s8_uart
# End of SenseAir CO2 Sensor Code
- rx_pin: D5
baud_rate: 9600
id: pms5003_uart
i2c:
sda: D2
scl: D1
# Particulate Matter Sensor Configuration
# https://esphome.io/components/sensor/pmsx003.html?highlight=pms5003
sensor:
- platform: pmsx003
type: PMSX003
pm_1_0:
name: "${nice_name} PM <1.0µm"
id: pm1
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_2_5:
name: "${nice_name} PM <2.5µm"
id: pm2
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_10_0:
name: "${nice_name} PM <10.0µm"
id: pm10
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
uart_id: pms5003_uart
# SenseAir CO₂ Sensor
# https://esphome.io/components/sensor/senseair.html
# Comment out this section if SenseAir CO2 Sensor is not present
- platform: senseair
co2:
name: "${nice_name} CO₂"
id: co2
update_interval: 30s
uart_id: senseair_s8_uart
# End of SenseAir CO2 Sensor Code
# SHT3X-D Temperature+Humidity Sensor
# https://esphome.io/components/sensor/sht3xd.html?highlight=sht31
- platform: sht3xd
temperature:
name: "${nice_name} Temperature"
id: temp
humidity:
name: "${nice_name} Humidity"
id: humidity
address: 0x44
update_interval: 30s
# Wi-Fi Signal Quality
- platform: wifi_signal
name: "${nice_name} WiFi Signal"
id: airgradient_wifi_signal
update_interval: 30s
font:
# Font to use on the display
# Open Source DejaVu fonts
# https://dejavu-fonts.github.io
- file: 'fonts/DejaVuSans.ttf'
id: regular
size: 15
glyphs: ' !"%()+,-.:/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz°₂₅'
- file: 'fonts/DejaVuSans-Bold.ttf'
id: bold
size: 26
display:
- platform: ssd1306_i2c
# https://esphome.io/components/display/ssd1306.html?highlight=display
model: "SSD1306 64x48"
id: oled_display
reset_pin: D0
address: 0x3C
# rotation: 180 # Enable to 180 to flip screen around
pages:
- id: display_pm2
lambda: |-
it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "PM₂.₅");
it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.0f",id(pm2).state);
# Comment out this section if SenseAir CO2 Sensor is not present
- id: display_co2
lambda: |-
it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "CO₂");
it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.0f",id(co2).state);
# End of SenseAir CO2 Sensor Code
- id: display_temp
lambda: |-
it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "Temp °C");
it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.1f",id(temp).state);
# - id: display_tempf
# lambda: |-
# it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "Temp °F");
# it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.1f",id(temp).state*9/5+32);
- id: display_humidity
lambda: |-
it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "Humidity");
it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.0f%%",id(humidity).state);
# - id: display_eco2
# lambda: |-
# it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "CO₂");
# it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.0f",id(eco2).state);
# - id: display_tvoc
# lambda: |-
# it.print(32, 0, id(regular), TextAlign::TOP_CENTER, "TVOC");
# it.printf(32, 48, id(bold), TextAlign::BOTTOM_CENTER, "%.0f",id(tvoc).state);
# - id: display_status
# lambda: |-
# it.printf(0, 0, id(regular),"%s", id(esp_ip).state.c_str());
interval:
# Cycle through page on display
- interval: ${display_update}
then:
- display.page.show_next: oled_display
- component.update: oled_display