Getting started with template triggers

I can’t get my head around template triggers, perhaps someone would help with the syntax please? My desire is to create an automation that checks a sensor numeric value against a helper - n (the helper is used in two automations to create hysteresis

I have a a sensor : sensor.fire_temp
I have a helper : input_number.fire.fan.low
The offset I want to use is 10 (degrees)

So the trigger I want is effectively, sensor.fire_temp is below (input_number.fire.fan.low - 10).

Could someone tell me the yaml to use for this trigger please?

If it wasn’t for the offset you could do that with a numeric state trigger.

Anyway, for it to trigger the template has to change from false to true. So you need some sort of mathematical test. Like this:

trigger:
  - platform: template
    value_template: "{{ states('sensor.fire_temp')|float(0) < states('input_number.fire.fan.low)|float(0) - 10 }}"

You can read more about how templates are constructed here:

1 Like

I don’t think that the input_number entity_id is valid:

you have:

states('input_number.fire.fan.low)

should be - no dots in object_id (the part after the domain):

states('input_number.fire_fan_low)

or something like that. check it in the states page to be sure.

2 Likes

Good catch. I just copied and pasted.

2 Likes