diff --git a/airgradient-basic.bin b/airgradient-basic.bin index 5f1591b..ed4d6d5 100644 Binary files a/airgradient-basic.bin and b/airgradient-basic.bin differ diff --git a/airgradient-one.bin b/airgradient-one.bin index 62594ce..e097b24 100644 Binary files a/airgradient-one.bin and b/airgradient-one.bin differ diff --git a/airgradient-open-air-o-1ppt.bin b/airgradient-open-air-o-1ppt.bin index 616d34c..292e12d 100644 Binary files a/airgradient-open-air-o-1ppt.bin and b/airgradient-open-air-o-1ppt.bin differ diff --git a/airgradient-open-air-o-1pst.bin b/airgradient-open-air-o-1pst.bin index 7d2dc9b..6f37fce 100644 Binary files a/airgradient-open-air-o-1pst.bin and b/airgradient-open-air-o-1pst.bin differ diff --git a/airgradient-pro.bin b/airgradient-pro.bin index 7ff6617..4791886 100644 Binary files a/airgradient-pro.bin and b/airgradient-pro.bin differ diff --git a/full_config/ag-basic.yaml b/full_config/ag-basic.yaml index fd2829f..c27972f 100644 --- a/full_config/ag-basic.yaml +++ b/full_config/ag-basic.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.0 + config_version: 4.0.1 co2_offset: '0' name: ag-basic friendly_name: AG Basic @@ -10,7 +10,7 @@ esphome: name_add_mac_suffix: false project: name: mallocarray.airgradient - version: 4.0.0 + version: 4.0.1 min_version: 2024.6.0 on_boot: - priority: 200.0 @@ -134,18 +134,24 @@ sensor: device_class: pm25 filters: - lambda: !lambda |- + float result = 0.0; if (x == 0.0) { - return 0.0; + result = 0.0; } else if (x < 30.0) { - return((0.524 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 50.0) { - return((0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75; } else if (x < 210.0) { - return((0.786 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 260.0) { - return((0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5))); + result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); } else { - return(2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2))); + result = 2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false diff --git a/full_config/ag-one.yaml b/full_config/ag-one.yaml index 041650c..538771c 100644 --- a/full_config/ag-one.yaml +++ b/full_config/ag-one.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.0 + config_version: 4.0.1 co2_offset: '0' voc_learning_time_offset_hours: '12' nox_learning_time_offset_hours: '12' @@ -16,7 +16,7 @@ esphome: name_add_mac_suffix: false project: name: mallocarray.airgradient - version: 4.0.0 + version: 4.0.1 min_version: 2024.6.0 on_boot: - priority: 200.0 @@ -146,18 +146,24 @@ sensor: device_class: pm25 filters: - lambda: !lambda |- + float result = 0.0; if (x == 0.0) { - return 0.0; + result = 0.0; } else if (x < 30.0) { - return((0.524 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 50.0) { - return((0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75; } else if (x < 210.0) { - return((0.786 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 260.0) { - return((0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5))); + result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); } else { - return(2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2))); + result = 2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false @@ -799,7 +805,7 @@ display: lambda: !lambda |- it.printf(0, 0, id(open_sans_14), "ID:"); it.printf(128, 0, id(open_sans_14), TextAlign::TOP_RIGHT, "%s", get_mac_address().c_str()); - it.printf(0, 21, id(open_sans_14), "Config Ver: 4.0.0"); + it.printf(0, 21, id(open_sans_14), "Config Ver: 4.0.1"); it.printf(0, 42, id(open_sans_14), "AG One"); - id: summary1 lambda: !lambda |- @@ -1259,9 +1265,9 @@ binary_sensor: then: - logger.log: format: Toggling display betwen C and F - tag: main args: [] level: DEBUG + tag: main - switch.toggle: id: display_in_f invalid_cooldown: 1s @@ -1274,9 +1280,9 @@ binary_sensor: then: - logger.log: format: Starting manual CO2 calibration - tag: main args: [] level: DEBUG + tag: main - senseair.background_calibration: id: senseair_s8 - delay: 70s diff --git a/full_config/ag-open-air-o-1ppt.yaml b/full_config/ag-open-air-o-1ppt.yaml index ff56753..5110795 100644 --- a/full_config/ag-open-air-o-1ppt.yaml +++ b/full_config/ag-open-air-o-1ppt.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.0 + config_version: 4.0.1 voc_learning_time_offset_hours: '12' nox_learning_time_offset_hours: '12' name: ag-open-air-o-1ppt @@ -11,7 +11,7 @@ esphome: name_add_mac_suffix: false project: name: mallocarray.airgradient - version: 4.0.0 + version: 4.0.1 min_version: 2024.6.0 on_boot: - priority: 200.0 @@ -236,18 +236,24 @@ sensor: accuracy_decimals: 0 state_class: measurement lambda: !lambda |- + float result = 0.0; if (id(pm_2_5_raw).state == 0.0) { - return 0.0; + result = 0.0; } else if (id(pm_2_5_raw).state < 30.0) { - return((0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 50.0) { - return((0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 210.0) { - return((0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 260.0) { - return((0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5))); + result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); } else { - return(2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2))); + result = 2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false @@ -394,18 +400,24 @@ sensor: accuracy_decimals: 0 state_class: measurement lambda: !lambda |- + float result = 0.0; if (id(pm_2_5_2_raw).state == 0.0) { - return 0.0; + result = 0.0; } else if (id(pm_2_5_2_raw).state < 30.0) { - return((0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 50.0) { - return((0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 210.0) { - return((0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 260.0) { - return((0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5))); + result = (0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5)); } else { - return(2.966 + (0.69 * id(pm_2_5_2_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2))); + result = 2.966 + (0.69 * id(pm_2_5_2_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false diff --git a/full_config/ag-open-air-o-1pst.yaml b/full_config/ag-open-air-o-1pst.yaml index cbc1b93..d742e99 100644 --- a/full_config/ag-open-air-o-1pst.yaml +++ b/full_config/ag-open-air-o-1pst.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.0 + config_version: 4.0.1 co2_offset: '0' voc_learning_time_offset_hours: '12' nox_learning_time_offset_hours: '12' @@ -12,7 +12,7 @@ esphome: name_add_mac_suffix: false project: name: mallocarray.airgradient - version: 4.0.0 + version: 4.0.1 min_version: 2024.6.0 on_boot: - priority: 200.0 @@ -237,18 +237,24 @@ sensor: accuracy_decimals: 0 state_class: measurement lambda: !lambda |- + float result = 0.0; if (id(pm_2_5_raw).state == 0.0) { - return 0.0; + result = 0.0; } else if (id(pm_2_5_raw).state < 30.0) { - return((0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 50.0) { - return((0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 210.0) { - return((0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; } else if (id(pm_2_5_raw).state < 260.0) { - return((0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5))); + result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); } else { - return(2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2))); + result = 2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false diff --git a/full_config/ag-pro.yaml b/full_config/ag-pro.yaml index fff558a..33f07a6 100644 --- a/full_config/ag-pro.yaml +++ b/full_config/ag-pro.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.0 + config_version: 4.0.1 co2_offset: '0' voc_learning_time_offset_hours: '12' nox_learning_time_offset_hours: '12' @@ -12,7 +12,7 @@ esphome: name_add_mac_suffix: false project: name: mallocarray.airgradient - version: 4.0.0 + version: 4.0.1 min_version: 2024.6.0 on_boot: - priority: 200.0 @@ -136,18 +136,24 @@ sensor: device_class: pm25 filters: - lambda: !lambda |- + float result = 0.0; if (x == 0.0) { - return 0.0; + result = 0.0; } else if (x < 30.0) { - return((0.524 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.524 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 50.0) { - return((0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75; } else if (x < 210.0) { - return((0.786 * x) - (0.0862 * id(humidity).state) + 5.75); + result = (0.786 * x) - (0.0862 * id(humidity).state) + 5.75; } else if (x < 260.0) { - return((0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5))); + result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); } else { - return(2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2))); + result = 2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2)); + } + if (result <= 0.0) { + return 0.0; + } else { + return result; } disabled_by_default: false force_update: false @@ -744,7 +750,7 @@ display: lambda: !lambda |- it.printf(0, 0, id(open_sans_14), "ID:"); it.printf(128, 0, id(open_sans_14), TextAlign::TOP_RIGHT, "%s", get_mac_address().c_str()); - it.printf(0, 21, id(open_sans_14), "Config Ver: 4.0.0"); + it.printf(0, 21, id(open_sans_14), "Config Ver: 4.0.1"); it.printf(0, 42, id(open_sans_14), "AG Pro"); - id: blank lambda: !lambda |- @@ -914,8 +920,8 @@ binary_sensor: - logger.log: format: Toggling display betwen C and F level: DEBUG - tag: main args: [] + tag: main - switch.toggle: id: display_in_f invalid_cooldown: 1s @@ -929,8 +935,8 @@ binary_sensor: - logger.log: format: Starting manual CO2 calibration level: DEBUG - tag: main args: [] + tag: main - senseair.background_calibration: id: senseair_s8 - delay: 70s