Hi all,
I need a little help with my first template which is a simple calculation.
#
# Dewpoint Calculations
#
# Simplified formula: Td = T - ((100 - RH)/5.)
#
# where Td is dew point temperature (in degrees Celsius),
# T is observed temperature (in degrees Celsius), and
# RH is relative humidity (in percent).
# This relationship is fairly accurate for relative humidity values above 50%.
#
# T = sensor.t_buiten_2
# unit of Measurement °C
#
# RH = sensor.humidity_buiten_bme280
#
template:
- sensor:
dew_point:
friendly_name: “Dewpoint-Home”
unit_of_measurement: “°C”
value_template: >
{% set T = states('sensor.t_buiten_2') | float %}
{% set RH = states('sensor.humidity_buiten_bme280') | float %}
{{ (T - ((100 - RH) / 5 ))|round(2) }}
#
# End of Dewpoint calculation
#
This calculation works - it delivers a numerical result (-3.44) in the template editor under developer tools. Made me happy.
The problem starts when I simply drop this code into configuration.yaml or into automation.yaml.
I get errors with the Template integration not existing in the first case, and template not being a valid option for the latter.
“Logger: homeassistant.config
Source: config.py:508 First occurred: 16:32:10 (1 occurrences) Last logged: 16:32:10
Invalid config for [automation]: [template] is an invalid option for [automation].
Check: automation- >template. (See /config/configuration.yaml, line 8)”
So what am I not doing which I should be doing, what is missing ?
Thanks for the syntax correction. I am sure it was helpful.
However it did not solve the problem.
I did manage to get things working by creating a template.yaml file, using the include !template.yaml line in configuration.yaml and placing the code in there.
But still not sure what the issue was with “template is an invalid option”.
If you tried what I posted and it failed to work then you did something wrong.
The example I posted is syntactically correct and, if copy-pasted correctly into configuration.yaml, it will pass the configuration check and, after executing Reload Template Entities, will produce a new entity named sensor.dewpoint_home.
If you copy-pasted it into template.yaml then you must remove the first line from the example containing template: otherwise it will report an error. Why? Because you are effectively duplicating the template: key.
It contains a second instance of template: key. Why? Because we literally did specify it twice. The first time in template: !include templates.yaml and the second time inside the templates.yaml file.