Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airgradient-open-air-o-1pst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
substitutions:
name: "ag-open-air-o-1pst"
friendly_name: "AG Open Air O-1PST"
config_version: 2.0.0
config_version: 2.0.1
name_add_mac_suffix: "false" # Must have quotes around value

# Enable Home Assistant API
Expand Down
20 changes: 16 additions & 4 deletions packages/sensor_pms5003t.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ sensor:
pm_2_5:
name: "PM 2.5"
id: pm_2_5
device_class: pm25 # Added to report properly to HomeKit
device_class: pm25 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_1_0:
name: "PM 1.0"
id: pm_1_0
device_class: pm1 # Added to report properly to HomeKit
device_class: pm1 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_10_0:
name: "PM 10.0"
id: pm_10_0
device_class: pm10 # Added to report properly to HomeKit
device_class: pm10 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
Expand All @@ -39,13 +39,25 @@ sensor:
name: "Temperature"
id: temp
filters:
# https://www.airgradient.com/blog/slr-temperature-example/
# - lambda: return (x - 4.55) / 0.83; # Once the negative number issue fix is merged in https://github.com/esphome/issues/issues/3814
- lambda: !lambda |-
// Fix negative values for now
if (x > 6000) {
return (x - 6553.6 - 4.55) / 0.83;
}
return (x - 4.55) / 0.83;
- sliding_window_moving_average:
window_size: 30
send_every: 30
humidity:
name: "Humidity"
id: humidity
filters:
# https://www.airgradient.com/blog/linear-regression-improves-sensor-accuracy/
# - lambda: return x * 1.500574 - 4.76;
# https://forum.airgradient.com/t/open-air-outdoor-air-quality-monitor-humidity-readings-are-off/1171/2
- lambda: return x * 1.3921 - 1.0245;
- sliding_window_moving_average:
window_size: 30
send_every: 30
Expand All @@ -60,7 +72,7 @@ sensor:
icon: "mdi:air-filter"
accuracy_decimals: 0
filters:
- skip_initial: 10 # Need valid data from PM 2.5 sensor before able to calculate
- skip_initial: 1 # Need valid data from PM 2.5 sensor before able to calculate
lambda: |-
// https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI
// Borrowed from https://github.com/kylemanna/sniffer/blob/master/esphome/sniffer_common.yaml
Expand Down
22 changes: 18 additions & 4 deletions packages/sensor_pms5003t_extended_life.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,38 @@ sensor:
pm_2_5:
name: "PM 2.5"
id: pm_2_5
device_class: pm25 # Added to report properly to HomeKit
device_class: pm25 # Added to report properly to Homekit
pm_1_0:
name: "PM 1.0"
id: pm_1_0
device_class: pm1 # Added to report properly to HomeKit
device_class: pm1 # Added to report properly to Homekit
pm_10_0:
name: "PM 10.0"
id: pm_10_0
device_class: pm10 # Added to report properly to HomeKit
device_class: pm10 # Added to report properly to Homekit
pm_0_3um:
name: "PM 0.3"
id: pm_0_3um
temperature:
name: "Temperature"
id: temp
filters:
# https://www.airgradient.com/blog/slr-temperature-example/
# - lambda: return (x - 4.55) / 0.83; # Once the negative number issue fix is merged in https://github.com/esphome/issues/issues/3814
- lambda: !lambda |-
// Fix negative values for now
if (x > 6000) {
return (x - 6553.6 - 4.55) / 0.83;
}
return (x - 4.55) / 0.83;
humidity:
name: "Humidity"
id: humidity
filters:
# https://www.airgradient.com/blog/linear-regression-improves-sensor-accuracy/
# - lambda: return x * 1.500574 - 4.76;
# https://forum.airgradient.com/t/open-air-outdoor-air-quality-monitor-humidity-readings-are-off/1171/2
- lambda: return x * 1.3921 - 1.0245;
update_interval: 2min


Expand All @@ -37,7 +51,7 @@ sensor:
icon: "mdi:air-filter"
accuracy_decimals: 0
filters:
- skip_initial: 10 # Need valid data from PM 2.5 sensor before able to calculate
- skip_initial: 1 # Need valid data from PM 2.5 sensor before able to calculate
lambda: |-
// https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI
// Borrowed from https://github.com/kylemanna/sniffer/blob/master/esphome/sniffer_common.yaml
Expand Down
90 changes: 90 additions & 0 deletions packages/sensor_pms5003t_uncorrected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
sensor:
- platform: pmsx003
# Default interval of updating every second, but using an average over the last 30 seconds/readings
# PMS5003T with temperature and humidity https://esphome.io/components/sensor/pmsx003.html
type: PMS5003T
uart_id: pms5003_uart
pm_2_5:
name: "PM 2.5"
id: pm_2_5
device_class: pm25 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_1_0:
name: "PM 1.0"
id: pm_1_0
device_class: pm1 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_10_0:
name: "PM 10.0"
id: pm_10_0
device_class: pm10 # Added to report properly to Homekit
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
pm_0_3um:
name: "PM 0.3"
id: pm_0_3um
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
temperature:
name: "Temperature"
id: temp
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
humidity:
name: "Humidity"
id: humidity
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30


- platform: template
# Depends on another sensor providing an ID of pm_2_5 such as a pms5003
name: "PM 2.5 AQI"
id: pm_2_5_aqi
update_interval: 5 min
unit_of_measurement: "AQI"
icon: "mdi:air-filter"
accuracy_decimals: 0
filters:
- skip_initial: 1 # Need valid data from PM 2.5 sensor before able to calculate
lambda: |-
// https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI
// Borrowed from https://github.com/kylemanna/sniffer/blob/master/esphome/sniffer_common.yaml
if (id(pm_2_5).state <= 12.0) {
// good
return((50.0 - 0.0) / (12.0 - 0.0) * (id(pm_2_5).state - 0.0) + 0.0);
} else if (id(pm_2_5).state <= 35.4) {
// moderate
return((100.0 - 51.0) / (35.4 - 12.1) * (id(pm_2_5).state - 12.1) + 51.0);
} else if (id(pm_2_5).state <= 55.4) {
// usg
return((150.0 - 101.0) / (55.4 - 35.5) * (id(pm_2_5).state - 35.5) + 101.0);
} else if (id(pm_2_5).state <= 150.4) {
// unhealthy
return((200.0 - 151.0) / (150.4 - 55.5) * (id(pm_2_5).state - 55.5) + 151.0);
} else if (id(pm_2_5).state <= 250.4) {
// very unhealthy
return((300.0 - 201.0) / (250.4 - 150.5) * (id(pm_2_5).state - 150.5) + 201.0);
} else if (id(pm_2_5).state <= 350.4) {
// hazardous
return((400.0 - 301.0) / (350.4 - 250.5) * (id(pm_2_5).state - 250.5) + 301.0);
} else if (id(pm_2_5).state <= 500.4) {
// hazardous 2
return((500.0 - 401.0) / (500.4 - 350.5) * (id(pm_2_5).state - 350.5) + 401.0);
} else {
return(500);
}