In the documentation on Automations, there is a screenshot of the UI for configuring the trigger. There is no explanation on what the Value Template is for or how to use it. Just curious.
template is essentially code you can write to express what you want. the code will evaluate to some value… a string or a number or boolean true/false. etc. more info here:
so for example, if you want the trigger to be 10 higher than the value of a certain entity, you might do something like:
{{ states('light.my_entity') + 10 }}
or if you want it to be compared not to an entity, but an attribute in an entity, you would do something like:
{{ state_attr('sensor.name', 'attribute_you_want') }}
It gives you a lot of flexibility in your triggers by evaluating complex expressions or even just allowing you to fine tune something that HA might not be able to evaluate in the UI.
For example, you might want to compare if two devices are on:
{{ states('light.light_1') == states('light.light_2') }}
Personally I find myself using templates more and more often, in fact I probably use them more on new automations than the stock stuff.
For a trigger here is an example that will trigger when attic temp equals or exceeds the input_number value.
{{ (states('sensor.attic_fan_control_attic_temperature') | float >= states('input_number.fan_1_on_temp') | float) }}
The use of value_template
in a numeric state trigger is documented in the Numeric State Trigger section of this page:
Most of these answers are about the template trigger rather than the value template applied to a numeric state trigger. Except for @atlflyer, they got it right.
Basically instead of using the number your sensor reports it will alter that number with the value_template
first, then check for the above
or below
numeric state trigger.
Great, thanks.