Skip to content

Commit

Permalink
Add packages files for upcoming modification
Browse files Browse the repository at this point in the history
  • Loading branch information
MallocArray committed Jan 1, 2024
1 parent 93d5f55 commit 420b7a4
Show file tree
Hide file tree
Showing 25 changed files with 1,298 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
secrets.yaml
desktop.ini
56 changes: 56 additions & 0 deletions packages/airgradient_api_d1_mini.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
interval:
- interval: 2.5min
# Send data to AirGradient API server
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# https://api.airgradient.com/public/docs/api/v1/
# AirGradient URL with the MAC address all lower case
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
headers:
Content-Type: application/json
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
json:
wifi: !lambda return to_string(id(wifi_dbm).state);
pm01: !lambda return to_string(id(pm_1_0).state);
pm02: !lambda return to_string(id(pm_2_5).state);
pm10: !lambda return to_string(id(pm_10_0).state);
pm003_count: !lambda return to_string(id(pm_0_3um).state);
rco2: !lambda return to_string(id(co2).state);
atmp: !lambda return to_string(id(temp).state);
rhum: !lambda return to_string(id(humidity).state);
tvoc_index: !lambda return to_string(id(voc).state);
nox_index: !lambda return to_string(id(nox).state);

switch:
- platform: template
name: "Upload to AirGradient Dashboard"
id: upload_airgradient
restore_mode: RESTORE_DEFAULT_ON
optimistic: True

esphome:
on_boot:
priority: 200 # Network connections setup
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
headers:
Content-Type: application/json
json:
wifi: !lambda return to_string(-50);

http_request:
# Used to support POST request to send data to AirGradient
# https://esphome.io/components/http_request.html
54 changes: 54 additions & 0 deletions packages/airgradient_api_d1_mini_no_sgp41.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
interval:
- interval: 2.5min
# Send data to AirGradient API server
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# https://api.airgradient.com/public/docs/api/v1/
# AirGradient URL with the MAC address all lower case
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
headers:
Content-Type: application/json
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
json:
wifi: !lambda return to_string(id(wifi_dbm).state);
pm01: !lambda return to_string(id(pm_1_0).state);
pm02: !lambda return to_string(id(pm_2_5).state);
pm10: !lambda return to_string(id(pm_10_0).state);
pm003_count: !lambda return to_string(id(pm_0_3um).state);
rco2: !lambda return to_string(id(co2).state);
atmp: !lambda return to_string(id(temp).state);
rhum: !lambda return to_string(id(humidity).state);

switch:
- platform: template
name: "Upload to AirGradient Dashboard"
id: upload_airgradient
restore_mode: RESTORE_DEFAULT_ON
optimistic: True

esphome:
on_boot:
priority: 200 # Network connections setup
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address().substr(6,11) + "/measures";
headers:
Content-Type: application/json
json:
wifi: !lambda return to_string(-50);

http_request:
# Used to support POST request to send data to AirGradient
# https://esphome.io/components/http_request.html
56 changes: 56 additions & 0 deletions packages/airgradient_api_esp32-c3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
interval:
- interval: 2.5min
# Send data to AirGradient API server
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# https://api.airgradient.com/public/docs/api/v1/
# AirGradient URL with the MAC address all lower case
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address() + "/measures";
headers:
Content-Type: application/json
# "!lambda return to_string(id(pm_2_5).state);" Converts sensor output from double to string
json:
wifi: !lambda return to_string(id(wifi_dbm).state);
pm01: !lambda return to_string(id(pm_1_0).state);
pm02: !lambda return to_string(id(pm_2_5).state);
pm10: !lambda return to_string(id(pm_10_0).state);
pm003_count: !lambda return to_string(id(pm_0_3um).state);
rco2: !lambda return to_string(id(co2).state);
atmp: !lambda return to_string(id(temp).state);
rhum: !lambda return to_string(id(humidity).state);
tvoc_index: !lambda return to_string(id(voc).state);
nox_index: !lambda return to_string(id(nox).state);

switch:
- platform: template
name: "Upload to AirGradient Dashboard"
id: upload_airgradient
restore_mode: RESTORE_DEFAULT_ON
optimistic: True

esphome:
on_boot:
priority: 200 # Network connections setup
then:
if:
condition:
switch.is_on: upload_airgradient
then:
- http_request.post:
# Return wifi signal -50 as soon as device boots to show activity on AirGradient Dashboard site
# Using -50 instead of actual value as the wifi_signal sensor has not reported a value at this point in boot process
url: !lambda |-
return "http://hw.airgradient.com/sensors/airgradient:" + get_mac_address() + "/measures";
headers:
Content-Type: application/json
json:
wifi: !lambda return to_string(-50);

http_request:
# Used to support POST request to send data to AirGradient
# https://esphome.io/components/http_request.html
43 changes: 43 additions & 0 deletions packages/airgradient_d1_mini_board.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

esphome:
name: "${devicename}"
friendly_name: "${upper_devicename}"
name_add_mac_suffix: ${add_mac_suffix} # Set to false if you don't want part of the MAC address in the name
project:
name: mallocarray.airgradient
version: "$ag_esphome_config_version"
min_version: 2023.7.0

esp8266:
board: d1_mini
restore_from_flash: true # Used to store state of display config

# Enable logging
# https://esphome.io/components/logger.html
logger:
logs:
component: ERROR # Hiding warning messages about component taking a long time https://github.com/esphome/issues/issues/4717

# The captive portal is a fallback mechanism for when connecting to the configured WiFi fails.
# https://esphome.io/components/captive_portal.html
captive_portal:

# web_server: # Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.

uart:
# https://esphome.io/components/uart.html#uart
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: senseair_s8_uart

- rx_pin: D5
tx_pin: D6
baud_rate: 9600
id: pms5003_uart

i2c:
# https://esphome.io/components/i2c.html
sda: D2
scl: D1
frequency: 400kHz # 400kHz eliminates warnings about components taking a long time other than SGP40 component: https://github.com/esphome/issues/issues/4717
43 changes: 43 additions & 0 deletions packages/airgradient_esp32-c3_board.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

esphome:
name: "${devicename}"
friendly_name: "${upper_devicename}"
name_add_mac_suffix: ${add_mac_suffix} # Set to false if you don't want part of the MAC address in the name
project:
name: mallocarray.airgradient
version: "$ag_esphome_config_version"
min_version: 2023.7.0

esp32:
board: esp32-c3-devkitm-1

# Enable logging
# https://esphome.io/components/logger.html
logger:
baud_rate: 0 # Must disable serial logging as it conflicts with pms5003 uart pins and ESP32-C3 only has 2 hardware UART
logs:
component: ERROR # Hiding warning messages about component taking a long time https://github.com/esphome/issues/issues/4717

# The captive portal is a fallback mechanism for when connecting to the configured WiFi fails.
# https://esphome.io/components/captive_portal.html
captive_portal:

# web_server: # Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.

uart:
# https://esphome.io/components/uart.html#uart
- rx_pin: GPIO0 # Pin 12
tx_pin: GPIO1 # Pin 13
baud_rate: 9600
id: senseair_s8_uart

- rx_pin: GPIO20 # Pin 30 or RX
tx_pin: GPIO21 # Pin 31 or TX
baud_rate: 9600
id: pms5003_uart

i2c:
# https://esphome.io/components/i2c.html
sda: GPIO7 # Pin 21
scl: GPIO6 # Pin 20
frequency: 400kHz # 400kHz eliminates warnings about components taking a long time other than SGP40 component: https://github.com/esphome/issues/issues/4717
26 changes: 26 additions & 0 deletions packages/config_button.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
binary_sensor:
- platform: gpio
# Binary sensor to perform action when physical config button is pressed
# https://esphome.io/components/binary_sensor/index.html?highlight=on_multi_click
pin:
number: GPIO9
mode: INPUT_PULLUP
inverted: true
internal: true # Hide from displaying in HomeAssistant
name: "Configuration Button"
id: config_button
on_multi_click:
- timing: # Short Click
- ON for at most 1s
- OFF for at least 0.5s
then:
- logger.log: "Toggling display betwen C and F"
- switch.toggle: display_in_f
- timing: # Press and hold up to 5 seconds
- ON for 1s to 5s
- OFF for at least 0.5s
then:
- logger.log: "Starting manual CO2 calibration"
- senseair.background_calibration: senseair_s8
- delay: 70s
- senseair.background_calibration_result: senseair_s8
Loading

0 comments on commit 420b7a4

Please sign in to comment.