diff --git a/packages/vpd.yaml b/packages/vpd.yaml index 16e713891949cc739ba501270eaace14cf682e9a..597d6c4707358f38cd90c1ab4224cedc362c8326 100644 --- a/packages/vpd.yaml +++ b/packages/vpd.yaml @@ -5,12 +5,13 @@ sensor: update_interval: 5s accuracy_decimals: 2 unit_of_measurement: 'kPa' + <<: !include filter.yaml lambda: |- - float temperature = (id(mlx90614_temperature_object).state - 32) * 5/9; - float humidity = id(bme280_humidity).state; - float vpSaturation = 610.7 * pow(10, (7.5 * temperature / (temperature + 237.3))); - float vpDeficit = ((100.0 - humidity) / 100.0) * vpSaturation; - return vpDeficit / 1000; + // https://vpdchart.com/grow-guide/vpd.html#how-to-calculate-vpd + float vp_leaf = 610.7 * pow(10, 7.5 * id(mlx90614_temperature_object).state / (237.3+id(mlx90614_temperature_object).state)) / 1000; + float vp_air = 610.7 * pow(10, 7.5 * id(bme280_temperature).state / (237.3+id(bme280_temperature).state) ) / 1000 * id(bme280_humidity).state/100; + float vpd = vp_leaf - vp_air; + return vpd; prometheus: relabel: