Hi all,
First post here. Thank you so very much for this amazing piece of software, and all the work everyone puts into it.
I have been using hassio for about 8 months but havent really had much confidence with any serious config editing. I use node red for most of my automations and confess to being pretty scared of YAML and JSON.
I have a small indoor garden for micro herbs etc. I am running some automations for temperature and humidity etc and all is working lovely. What I’d like to do now is some maths to calculate the VPD based on the output of the temp and humidity sensors, and create a sensor output for it.
I keep getting syntax errors when i check the config that i simply dont understand!
Here is the error:
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘integer’) for dictionary value @ data[‘sensors’][‘vpd_veg’][‘value_template’]. Got “{% set veg_leaf_temp = ((states(‘sensor.temperature_158d000238bd6e’) | float) -2) %} {% set es = 0.6108 * e ** (17.27 * veg_leaf_temp / (veg_leaf_temp + 237.3)) %} {# Saturation vapor pressure in kPa #} {% set ea = ((states(‘sensor.humidity_158d000238bd6e’) | float) / 100 * es) %} {# Actual Vapor Pressure in kPa #} {% set vpd = (ea - es) %} {{ vpd | round 3}}\n”. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
and here is the relevent part of my config:
sensor:
- platform: template
sensors:
solar_angle_test:
friendly_name: "Sun test Angle"
unit_of_measurement: '°'
value_template: "{{ '%+.1f'|format(state_attr('sun.sun', 'elevation')) }}"
vpd_veg:
friendly_name: "VPD Veg"
unit_of_measurement: 'kPa'
value_template: >
{% set veg_leaf_temp = ((states('sensor.temperature_158d000238bd6e') | float) -2) %}
{% set es = 0.6108 * e ** (17.27 * veg_leaf_temp / (veg_leaf_temp + 237.3)) %} {# Saturation vapor pressure in kPa #}
{% set ea = ((states('sensor.humidity_158d000238bd6e') | float) / 100 * es) %} {# Actual Vapor Pressure in kPa #}
{% set vpd = (ea - es) %}
{{ vpd | round 3}}
Any light shed on this would be very appreciated. I got the basis for the caclulation from this thread: Heat Index / Apparent Temperature / Feels Like Temperature in a post by rasputin. Hes doing something quite similar.
The mechanics i want are to reduce the temp by 2 degrees, then perform this calculation:
Given T is temperature in degrees Celsius, and RH is relative humidity:
Saturation Vapor Pressure (es) =
0.6108 * exp(17.27 * T / (T + 237.3))
Actual Vapor Pressure (ea) =
RH / 100 * es
Vapor Pressure Deficit =
ea - es
Thanks very much in advance.