Condition for minium of time

Hello HA world,
I’m looking for a condition function to have a state for a minimum of time. I hope someone of you could help me. :grinning:
My Idea is something like this:

  - alias: "test"
    trigger:
      - platform: time_pattern
        minutes: '/7'
    condition:
      - condition: and
        conditions:
        - condition: template
          value_template: '{{ states.cover.room1.attributes.current_position > 70 }}'
          for:
            minutes: >10  # that my issue!  > time of state
    action:
      - service_template: input_boolean.on
        entity_id: input_boolean.test2

minutes: 10 Will be true for 10 minutes or more.

I notice you are using the time pattern trigger. This is rarely the best trigger to use. What are you trying to accomplish?

2 Likes

And the time_pattern should be a lot smaller, such that it checks all 30 seconds or so, not only every 7 minutes.

The condition you did in your original post only checks it every 7 minutes, so “for 10 minutes” only triggers after the second time it checks the state (14 minutes).

time_pattern minutes: /7:

  • 7 min => Don’t trigger
  • 14 min => Trigger

time_pattern seconds: /30:

  • 9:00 min => Don’t trigger
  • 9:30 min => Don’t trigger
  • 10:00 min => Trigger

Another tip: Also don’t use time_patterns too small (like 1 second) to avoid unnecessary resource usage.