Help on using input_number in automation

I have an automation checking the temperature of the home freezer and getting Goggle home to tell us if too high. It’s working great, but I would like to have the alarm-limit adjustable via a input_number in lovelace.

    name: Slider
    initial: -18
    min: -30
    max: -10
    step: 1


    platform: numeric_state
    entity_id: sensor.freezer_temperature
      minutes: 15

I tried wrapping the alarm limit like this
{{ states.input.number.temp_h_freezer.state }}
but that give a invalid key error.

Is there a way I can use the input_number instead of the hardcoded ‘-18.0’?

Unfortunately the numeric_state trigger does not accept a template for the above parameter. But you can use a template trigger like this:

    platform: template
    value_template: >
      {{ states('sensor.freezer_temperature')|float > states('input_number.temp_h_freezer')|float }}

This will trigger whenever the numeric value of sensor.freezer_temperature is higher than the numeric value of input_number.temp_h_freezer. It doesn’t do the “for 15 minutes” part. If you want that, too, then instead of putting the template in the automation trigger, you use it to create a binary_sensor. Then use the binary_sensor in the automation trigger as a state trigger with to: 'on' and the for parameter.

EDIT: “For the record”, I should probably also mention, I’m pretty sure the template trigger will fire whenever either of the entities change state (including attributes), and the comparison is true. So that’s another way it doesn’t work like the numeric_state trigger, which only fires when the threshold is crossed. But using a binary_sensor, in addition to allowing the “for” parameter, when also using the “to: ‘on’” parameter will make it work just like the numeric_state trigger, only firing when the threshold is crossed (and the binary_sensor becomes true.)

Works great (including a new binary_sensor), thanks!

EDIT: Ok, then it makes even more sense using a binary_sensor, since the alarm-limit is a ‘absolute’ level. Thanks again!