Automation: Numeric state variables

Is it possible to use a variable in an automation trigger state? I’ve tried a number of different forms of how this might be put, but none get past the configuration check;

  trigger:
    platform: numeric_state
    entity_id: input_number.sleep_inducer_breath_count
      below: "{{ input_number.sleep_inducer_minute_breaths }}"

This is what I want to achieve.

Grateful for any guidance.

First, below: should be at the same indentation level as platform: and entity_id:. Second, below: does not accept a template. But you can do this:

  trigger:
    platform: template
    value_template: >
      {{ states('input_number.sleep_inducer_breath_count')|float <
         states('input_number.sleep_inducer_minute_breaths')|float }}

This will trigger the first time the expression evaluates to true. After that it has to evaluate to false and then back to true to trigger again. That’s typically what you want.

1 Like

@pnbruckner Thank you, that has helped my understand considerably. I hadn’t also appreciated that the condition has to evaluate back to false in order for it to be triggered again, so I’ll apply that learning to the other things I’m trying to do here.