Maintaining VPD of Plant using a climate sensor and a smart plug operated humidifier (optionally add a RGB light for VPD status indication)

Title says it all. Been using it for a while and it works great. Change the parameters in the blueprint file if you want. Currently, it’s configured for Cannabis plant.

blueprint:
  name: Maintain VPD
  description: This blueprint helps maintain the VPD for plants by controlling a humidifier based on temperature, humidity, and VPD thresholds, and optionally sets the color of an RGB light based on the VPD value.
  domain: automation
  input:
    temperature_entity:
      name: Temperature Sensor
      description: Entity for the temperature of the plant
      selector:
        entity:
          domain: sensor
    humidity_entity:
      name: Humidity Sensor
      description: Entity for the humidity
      selector:
        entity:
          domain: sensor
    humidifier_switch:
      name: Humidifier Switch
      description: Switch entity to turn the humidifier on or off
      selector:
        entity:
          domain: switch
    light_entity:
      name: Light Entity
      description: Entity for the RGB light
      selector:
        entity:
          domain: light
      default: null
    min_vpd:
      name: Minimum VPD
      description: Minimum VPD number input
      selector:
        number:
          min: 0.0
          max: 10.0
          step: 0.1
    max_vpd:
      name: Maximum VPD
      description: Maximum VPD number input
      selector:
        number:
          min: 0.0
          max: 10.0
          step: 0.1
    delta:
      name: Delta
      description: Delta value for VPD adjustments
      selector:
        number:
          min: 0.0
          max: 5.0
          step: 0.1

trigger:
  - platform: state
    entity_id: !input temperature_entity
  - platform: state
    entity_id: !input humidity_entity

condition: []

action:
  - variables:
      temp: !input temperature_entity
      humidity: !input humidity_entity
      min_vpd: !input min_vpd
      max_vpd: !input max_vpd
      delta: !input delta
      light_entity: !input light_entity
      vpd: >
        {% set temp_k = states(temp) | float + 273.15 %}
        {% set es = 0.6108 * (2.71828 ** ((17.27 * (states(temp) | float)) / (states(temp) | float + 237.3))) %}
        {% set ea = states(humidity) | float / 100 * es %}
        {% set vpdvar = es - ea %}
        {{ vpdvar }}

  - choose:
      - conditions:
          - condition: template
            value_template: "{{ vpd < (min_vpd - delta) }}"
        sequence:
          - service: switch.turn_off
            target:
              entity_id: !input humidifier_switch
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ light_entity is not none }}"
                sequence:
                  - service: light.turn_on
                    target:
                      entity_id: !input light_entity
                    data:
                      rgb_color: [255, 0, 0] # Red color
      - conditions:
          - condition: template
            value_template: "{{ vpd > (max_vpd + delta) }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: !input humidifier_switch
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ light_entity is not none }}"
                sequence:
                  - service: light.turn_on
                    target:
                      entity_id: !input light_entity
                    data:
                      rgb_color: [255, 0, 0] # Red color
      - conditions:
          - condition: template
            value_template: "{{ (min_vpd - delta) <= vpd <= (max_vpd + delta) }}"
        sequence:
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ light_entity is not none }}"
                sequence:
                  - service: light.turn_on
                    target:
                      entity_id: !input light_entity
                    data:
                      rgb_color: [0, 255, 0] # Green color