Skip to content

Commit c439659

Browse files
committed
Only apply batch corrections if modified substitutions
1 parent 70ea323 commit c439659

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

packages/sensor_pms5003.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ sensor:
4343
lambda: |-
4444
// https://www.airgradient.com/blog/low-readings-from-pms5003/
4545
// Correction for sensor batches after 20231030
46+
// Only use the batch/individual calibration if the default scaling and intercept are changed
4647
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
4748
float pm_2_5_calibrated = 0;
48-
if (pm_2_5_calibrated_low < 31) {
49+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
4950
pm_2_5_calibrated = pm_2_5_calibrated_low;
5051
} else {
5152
pm_2_5_calibrated = id(pm_2_5_raw).state;

packages/sensor_pms5003_extended_life.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ sensor:
4242
lambda: |-
4343
// https://www.airgradient.com/blog/low-readings-from-pms5003/
4444
// Correction for sensor batches after 20231030
45+
// Only use the batch/individual calibration if the default scaling and intercept are changed
4546
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
4647
float pm_2_5_calibrated = 0;
47-
if (pm_2_5_calibrated_low < 31) {
48+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
4849
pm_2_5_calibrated = pm_2_5_calibrated_low;
4950
} else {
5051
pm_2_5_calibrated = id(pm_2_5_raw).state;

packages/sensor_pms5003t.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ sensor:
7474
lambda: |-
7575
// https://www.airgradient.com/blog/low-readings-from-pms5003/
7676
// Correction for sensor batches after 20231030
77+
// Only use the batch/individual calibration if the default scaling and intercept are changed
7778
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
7879
float pm_2_5_calibrated = 0;
79-
if (pm_2_5_calibrated_low < 31) {
80+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
8081
pm_2_5_calibrated = pm_2_5_calibrated_low;
8182
} else {
8283
pm_2_5_calibrated = id(pm_2_5_raw).state;

packages/sensor_pms5003t_2.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ sensor:
7171
lambda: |-
7272
// https://www.airgradient.com/blog/low-readings-from-pms5003/
7373
// Correction for sensor batches after 20231030
74-
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um_2).state + $pm_2_5_intercept;
74+
// Only use the batch/individual calibration if the default scaling and intercept are changed
75+
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
7576
float pm_2_5_calibrated = 0;
76-
if (pm_2_5_calibrated_low < 31) {
77+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
7778
pm_2_5_calibrated = pm_2_5_calibrated_low;
7879
} else {
7980
pm_2_5_calibrated = id(pm_2_5_2_raw).state;

packages/sensor_pms5003t_2_extended_life.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ sensor:
7474
lambda: |-
7575
// https://www.airgradient.com/blog/low-readings-from-pms5003/
7676
// Correction for sensor batches after 20231030
77-
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um_2).state + $pm_2_5_intercept;
77+
// Only use the batch/individual calibration if the default scaling and intercept are changed
78+
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
7879
float pm_2_5_calibrated = 0;
79-
if (pm_2_5_calibrated_low < 31) {
80+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
8081
pm_2_5_calibrated = pm_2_5_calibrated_low;
8182
} else {
8283
pm_2_5_calibrated = id(pm_2_5_2_raw).state;

packages/sensor_pms5003t_extended_life.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ sensor:
7272
lambda: |-
7373
// https://www.airgradient.com/blog/low-readings-from-pms5003/
7474
// Correction for sensor batches after 20231030
75+
// Only use the batch/individual calibration if the default scaling and intercept are changed
7576
float pm_2_5_calibrated_low = $pm_2_5_scaling_factor * id(pm_0_3um).state + $pm_2_5_intercept;
7677
float pm_2_5_calibrated = 0;
77-
if (pm_2_5_calibrated_low < 31) {
78+
if (pm_2_5_calibrated_low < 31 && ($pm_2_5_scaling_factor != 1 || $pm_2_5_intercept != 0)) {
7879
pm_2_5_calibrated = pm_2_5_calibrated_low;
7980
} else {
8081
pm_2_5_calibrated = id(pm_2_5_raw).state;

0 commit comments

Comments
 (0)