Skip to content

Commit 420b7a4

Browse files
committed
Add packages files for upcoming modification
1 parent 93d5f55 commit 420b7a4

25 files changed

+1298
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
secrets.yaml
2+
desktop.ini
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
interval:
2+
- interval: 2.5min
3+
# Send data to AirGradient API server
4+
then:
5+
if:
6+
condition:
7+
switch.is_on: upload_airgradient
8+
then:
9+
- http_request.post:
10+
# https://api.airgradient.com/public/docs/api/v1/
11+
# AirGradient URL with the MAC address all lower case
12+
url: !lambda |-
13+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
14+
headers:
15+
Content-Type: application/json
16+
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
17+
json:
18+
wifi: !lambda return to_string(id(wifi_dbm).state);
19+
pm01: !lambda return to_string(id(pm_1_0).state);
20+
pm02: !lambda return to_string(id(pm_2_5).state);
21+
pm10: !lambda return to_string(id(pm_10_0).state);
22+
pm003_count: !lambda return to_string(id(pm_0_3um).state);
23+
rco2: !lambda return to_string(id(co2).state);
24+
atmp: !lambda return to_string(id(temp).state);
25+
rhum: !lambda return to_string(id(humidity).state);
26+
tvoc_index: !lambda return to_string(id(voc).state);
27+
nox_index: !lambda return to_string(id(nox).state);
28+
29+
switch:
30+
- platform: template
31+
name: "Upload to AirGradient Dashboard"
32+
id: upload_airgradient
33+
restore_mode: RESTORE_DEFAULT_ON
34+
optimistic: True
35+
36+
esphome:
37+
on_boot:
38+
priority: 200 # Network connections setup
39+
then:
40+
if:
41+
condition:
42+
switch.is_on: upload_airgradient
43+
then:
44+
- http_request.post:
45+
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
46+
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
47+
url: !lambda |-
48+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
49+
headers:
50+
Content-Type: application/json
51+
json:
52+
wifi: !lambda return to_string(-50);
53+
54+
http_request:
55+
# Used to support POST request to send data to AirGradient
56+
# https://esphome.io/components/http_request.html
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
interval:
2+
- interval: 2.5min
3+
# Send data to AirGradient API server
4+
then:
5+
if:
6+
condition:
7+
switch.is_on: upload_airgradient
8+
then:
9+
- http_request.post:
10+
# https://api.airgradient.com/public/docs/api/v1/
11+
# AirGradient URL with the MAC address all lower case
12+
url: !lambda |-
13+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
14+
headers:
15+
Content-Type: application/json
16+
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
17+
json:
18+
wifi: !lambda return to_string(id(wifi_dbm).state);
19+
pm01: !lambda return to_string(id(pm_1_0).state);
20+
pm02: !lambda return to_string(id(pm_2_5).state);
21+
pm10: !lambda return to_string(id(pm_10_0).state);
22+
pm003_count: !lambda return to_string(id(pm_0_3um).state);
23+
rco2: !lambda return to_string(id(co2).state);
24+
atmp: !lambda return to_string(id(temp).state);
25+
rhum: !lambda return to_string(id(humidity).state);
26+
27+
switch:
28+
- platform: template
29+
name: "Upload to AirGradient Dashboard"
30+
id: upload_airgradient
31+
restore_mode: RESTORE_DEFAULT_ON
32+
optimistic: True
33+
34+
esphome:
35+
on_boot:
36+
priority: 200 # Network connections setup
37+
then:
38+
if:
39+
condition:
40+
switch.is_on: upload_airgradient
41+
then:
42+
- http_request.post:
43+
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
44+
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
45+
url: !lambda |-
46+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
47+
headers:
48+
Content-Type: application/json
49+
json:
50+
wifi: !lambda return to_string(-50);
51+
52+
http_request:
53+
# Used to support POST request to send data to AirGradient
54+
# https://esphome.io/components/http_request.html
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
interval:
2+
- interval: 2.5min
3+
# Send data to AirGradient API server
4+
then:
5+
if:
6+
condition:
7+
switch.is_on: upload_airgradient
8+
then:
9+
- http_request.post:
10+
# https://api.airgradient.com/public/docs/api/v1/
11+
# AirGradient URL with the MAC address all lower case
12+
url: !lambda |-
13+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address() + "/measures";
14+
headers:
15+
Content-Type: application/json
16+
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
17+
json:
18+
wifi: !lambda return to_string(id(wifi_dbm).state);
19+
pm01: !lambda return to_string(id(pm_1_0).state);
20+
pm02: !lambda return to_string(id(pm_2_5).state);
21+
pm10: !lambda return to_string(id(pm_10_0).state);
22+
pm003_count: !lambda return to_string(id(pm_0_3um).state);
23+
rco2: !lambda return to_string(id(co2).state);
24+
atmp: !lambda return to_string(id(temp).state);
25+
rhum: !lambda return to_string(id(humidity).state);
26+
tvoc_index: !lambda return to_string(id(voc).state);
27+
nox_index: !lambda return to_string(id(nox).state);
28+
29+
switch:
30+
- platform: template
31+
name: "Upload to AirGradient Dashboard"
32+
id: upload_airgradient
33+
restore_mode: RESTORE_DEFAULT_ON
34+
optimistic: True
35+
36+
esphome:
37+
on_boot:
38+
priority: 200 # Network connections setup
39+
then:
40+
if:
41+
condition:
42+
switch.is_on: upload_airgradient
43+
then:
44+
- http_request.post:
45+
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
46+
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
47+
url: !lambda |-
48+
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address() + "/measures";
49+
headers:
50+
Content-Type: application/json
51+
json:
52+
wifi: !lambda return to_string(-50);
53+
54+
http_request:
55+
# Used to support POST request to send data to AirGradient
56+
# https://esphome.io/components/http_request.html
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
esphome:
3+
name: "${devicename}"
4+
friendly_name: "${upper_devicename}"
5+
name_add_mac_suffix: ${add_mac_suffix} # Set to false if you don't want part of the MAC address in the name
6+
project:
7+
name: mallocarray.airgradient
8+
version: "$ag_esphome_config_version"
9+
min_version: 2023.7.0
10+
11+
esp8266:
12+
board: d1_mini
13+
restore_from_flash: true # Used to store state of display config
14+
15+
# Enable logging
16+
# https://esphome.io/components/logger.html
17+
logger:
18+
logs:
19+
component: ERROR # Hiding warning messages about component taking a long time https://github.com/esphome/issues/issues/4717
20+
21+
# The captive portal is a fallback mechanism for when connecting to the configured WiFi fails.
22+
# https://esphome.io/components/captive_portal.html
23+
captive_portal:
24+
25+
# web_server: # Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.
26+
27+
uart:
28+
# https://esphome.io/components/uart.html#uart
29+
- rx_pin: D4
30+
tx_pin: D3
31+
baud_rate: 9600
32+
id: senseair_s8_uart
33+
34+
- rx_pin: D5
35+
tx_pin: D6
36+
baud_rate: 9600
37+
id: pms5003_uart
38+
39+
i2c:
40+
# https://esphome.io/components/i2c.html
41+
sda: D2
42+
scl: D1
43+
frequency: 400kHz # 400kHz eliminates warnings about components taking a long time other than SGP40 component: https://github.com/esphome/issues/issues/4717
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
esphome:
3+
name: "${devicename}"
4+
friendly_name: "${upper_devicename}"
5+
name_add_mac_suffix: ${add_mac_suffix} # Set to false if you don't want part of the MAC address in the name
6+
project:
7+
name: mallocarray.airgradient
8+
version: "$ag_esphome_config_version"
9+
min_version: 2023.7.0
10+
11+
esp32:
12+
board: esp32-c3-devkitm-1
13+
14+
# Enable logging
15+
# https://esphome.io/components/logger.html
16+
logger:
17+
baud_rate: 0 # Must disable serial logging as it conflicts with pms5003 uart pins and ESP32-C3 only has 2 hardware UART
18+
logs:
19+
component: ERROR # Hiding warning messages about component taking a long time https://github.com/esphome/issues/issues/4717
20+
21+
# The captive portal is a fallback mechanism for when connecting to the configured WiFi fails.
22+
# https://esphome.io/components/captive_portal.html
23+
captive_portal:
24+
25+
# web_server: # Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.
26+
27+
uart:
28+
# https://esphome.io/components/uart.html#uart
29+
- rx_pin: GPIO0 # Pin 12
30+
tx_pin: GPIO1 # Pin 13
31+
baud_rate: 9600
32+
id: senseair_s8_uart
33+
34+
- rx_pin: GPIO20 # Pin 30 or RX
35+
tx_pin: GPIO21 # Pin 31 or TX
36+
baud_rate: 9600
37+
id: pms5003_uart
38+
39+
i2c:
40+
# https://esphome.io/components/i2c.html
41+
sda: GPIO7 # Pin 21
42+
scl: GPIO6 # Pin 20
43+
frequency: 400kHz # 400kHz eliminates warnings about components taking a long time other than SGP40 component: https://github.com/esphome/issues/issues/4717

packages/config_button.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
binary_sensor:
2+
- platform: gpio
3+
# Binary sensor to perform action when physical config button is pressed
4+
# https://esphome.io/components/binary_sensor/index.html?highlight=on_multi_click
5+
pin:
6+
number: GPIO9
7+
mode: INPUT_PULLUP
8+
inverted: true
9+
internal: true # Hide from displaying in HomeAssistant
10+
name: "Configuration Button"
11+
id: config_button
12+
on_multi_click:
13+
- timing: # Short Click
14+
- ON for at most 1s
15+
- OFF for at least 0.5s
16+
then:
17+
- logger.log: "Toggling display betwen C and F"
18+
- switch.toggle: display_in_f
19+
- timing: # Press and hold up to 5 seconds
20+
- ON for 1s to 5s
21+
- OFF for at least 0.5s
22+
then:
23+
- logger.log: "Starting manual CO2 calibration"
24+
- senseair.background_calibration: senseair_s8
25+
- delay: 70s
26+
- senseair.background_calibration_result: senseair_s8

0 commit comments

Comments
 (0)