I’m having a hard time finding info on this…hope someone knows.
I have some templates that get fairly complicated, I’d like to add some comments to make them more maintainable. It seems putting a #something
on an intermediate line messes things up or processes it as strings, is there some trick to making templates work properly and having comments on lines in the middle of the template code?
For example, I’m looking at something I wrote a while ago…
{% if ( states('sensor.downstairs_thermostat_air_temperature') | float(0) ) == 0 or ( states('sensor.downstairs_thermostat_humidity_filtered') | float(0) ) == 0 or ( states('sensor.basement_hall_humidity_filtered') | float(0) ) == 0 %}
# This case is if the temp is invalid we can't do the computation
0
{% else %}
# Crap I forgot what this was, but it was important
{% set t = states('sensor.downstairs_thermostat_air_temperature') | float(0) %}
{% set rh = (states('sensor.downstairs_thermostat_humidity_filtered') | float(0) + states('sensor.basement_hall_humidity_filtered') | float(0))/2 %}
{% set rh = (rh * 1.1) + 8 %}
{% set hi = 0.5 * (t + 61.0 + ((t-68.0)*1.2) + (rh*0.094)) %}
# Now print...maybe this was feels-like temperature idk
{{ (hi) | round(2,default=0) }}
{{t}}
{% endif %}
But it doesn’t work because those don’t actually seem to be processed as comments, but just text?