sensor:
- platform: template
  id: vpd
  name: "VPD"
  update_interval: 5s
  accuracy_decimals: 2
  unit_of_measurement: 'kPa'
  <<: !include filter.yaml
  lambda: |-
    // 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:
    vpd:
      id: vpd
      name: "Vapor Pressure Deficit"