Counter value

The Counter value condition passes when a counter helperA helper is a virtual entity you create inside Home Assistant. It is not backed by a physical device. Helpers store values, track state, or do calculations that your automations and dashboards need. [Learn more] matches the threshold you define. You can check whether a counter is above, below, within, or outside a range of values. Use it when you want an automation to continue only while a count stays under a limit, reaches a target, or falls within a range you set.

Labs

Requires the Purpose-specific triggers and conditions Labs preview feature. Enable it at Settings > System > Labs.

Using this condition from the user interface

If you prefer building automations visually, Home Assistant walks you through this condition step by step. You pick what to check, tweak a few options, and save. No YAML knowledge required.

To use this condition in an automation:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the And if section, select Add condition.
  4. Select what you want to check. Under By target (see Targets), pick the counter helper you want to check. You can also select an area, a floor, a device, or a label.
  5. From the conditions shown for that target, select Counter value.
  6. Under Threshold type, set how the value should be checked:
    1. Pick whether the value must be Above, Below, In range, or Outside range.
    2. Select Number or Entity:
      • Number: Enter a fixed number directly.
      • Entity: Use a counter, input_number, or number entity as the threshold.
      • For In range or Outside range, you need both a lower and upper value or entity.
      • If you do not have a helper yet, create it separately as a helperA helper is a virtual entity you create inside Home Assistant. It is not backed by a physical device. Helpers store values, track state, or do calculations that your automations and dashboards need. [Learn more] before using it here.
  7. Under Condition passes if (see Behavior), pick Any or All.
  8. Under For at least, set how long the counter must stay within the selected threshold before the condition passes.
  9. Select Save.

Options in the UI

Threshold type

The value the counter has to meet for the condition to pass. Options are Above, Below, In range, or Outside range. Number uses a fixed value. Entity uses the current value of a counter, input_number, or number entity.

Condition passes if

When multiple counters are targeted, controls how results combine. Pick Any to pass if at least one targeted counter matches, or All to pass only when every targeted counter matches. Default is Any.

For at least

How long the counter must stay within the selected threshold before the condition passes. Defaults to 00:00:00, so the condition passes immediately.

Using this condition in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, refer to this condition as counter.is_value. A basic example looks like this:

ConditionConditions are an optional part of an automation that will prevent an action from firing if they are not met. [Learn more]
condition: counter.is_value
target:
  entity_id: counter.exercise_breaks
options:
  threshold:
    type: below
    value:
      number: 5

This passes when counter.exercise_breaks is below 5.

To compare a counter against another entity:

ConditionConditions are an optional part of an automation that will prevent an action from firing if they are not met. [Learn more]
condition: counter.is_value
target:
  entity_id: counter.water_reminders
options:
  threshold:
    type: above
    value:
      entity: input_number.water_reminder_limit

This passes when counter.water_reminders is above the current value of input_number.water_reminder_limit.

To check whether a counter stays within a range:

ConditionConditions are an optional part of an automation that will prevent an action from firing if they are not met. [Learn more]
condition: counter.is_value
target:
  entity_id: counter.daily_check_ins
options:
  threshold:
    type: between
    value_min:
      number: 2
    value_max:
      number: 4

This passes when counter.daily_check_ins is between 2 and 4.

Options in YAML

YAML sometimes provides additional options for more complex use cases that are not available through the UI.

threshold map Required

The value the counter has to meet for the condition to pass:

  • above: Sets a minimum
  • below: Sets a maximum
  • between: Defines a range
  • outside: Defines an outside-range

For above and below, use value with either number or entity. For between and outside, use value_min and value_max, each with either number or entity. Entities can be from the counter, input_number, or number domains. For example:

threshold:
  type: between
  value_min:
    entity: input_number.break_goal_min
  value_max:
    number: 6

When you use an entity, its current value is read when the condition is evaluated.

behavior string

Controls how results combine when multiple counters are targeted. Accepts all or any.

for string

How long the counter must stay within the selected threshold before the condition passes. Accepts a duration string like 00:05:00 for five minutes.

Targets of the condition

This condition requires a target. The target is the object that Home Assistant will check. You can point the condition at a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label, and Home Assistant will evaluate every matching counter entity behind that target.

  • Entity: one specific counter entity, such as counter.living_room.
  • Device: every counter entity that belongs to a device.
  • Area: every counter entity in a room or area.
  • Floor: every counter entity on a floor.
  • Label: every counter entity that shares a label.

You can also select different target types in one condition. For example, you can add a specific entity and an area as targets in the same condition to check both of them at once.

Behavior with multiple targets

When you target more than one entity (or select an area, floor, or label that contains several), the Condition passes if option controls how the results combine:

  • Any (default): the condition passes if at least one of the targeted entities matches. For example, if you check three smoke sensors and only one of them detects smoke, the condition still passes. This is useful for questions like “is there smoke anywhere in the house?”
  • All: the condition passes only when every targeted entity matches. For example, if you check the same three smoke sensors, the condition passes only once all three report cleared. This is useful for “is the entire house safe now?” checks, so your automation does not send an all-clear while one room still has a reading.

Good to know

  • Counters in the unavailable or unknown state are skipped for Any and fail for All.
  • If the counter leaves the selected threshold before the For at least time finishes, the timer resets.
  • When you use an entity as the threshold, Home Assistant reads that entity’s current value each time the condition is checked.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, open an automation, and add this condition. Trigger the automation with and without the condition met, and watch whether it continues or stops.

More examples

Real scenarios where this condition gates an automation. Copy any example and adapt it to your setup.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: stop incrementing a break counter after the daily goal

If you use a counter helper to track short exercise breaks, this condition can stop the count after the daily goal has been reached.

  • Trigger: Input button pressed
  • Condition: Counter value
    • Target: Exercise break counter
    • Threshold type: Below 5
  • Action: Increment counter
YAML example for limiting a daily break counter
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Increment the break counter only while it is below the daily goal"
triggers:
  - trigger: state
    entity_id: input_button.exercise_break_done
conditions:
  - condition: counter.is_value
    target:
      entity_id: counter.exercise_breaks
    options:
      threshold:
        type: below
        value:
          number: 5
actions:
  - action: counter.increment
    target:
      entity_id: counter.exercise_breaks

Automation: run a bedtime script only while a reminder counter is in range

If you have created a script and a counter helper for evening tasks, you can run the script only while the counter stays within a range you choose.

  • Trigger: At 21:00
  • Condition: Counter value
    • Target: Evening reminder counter
    • Threshold type: In range 1 to 3
  • Action: Turn on script
YAML example for a counter-based bedtime script
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Run the bedtime script while the reminder counter is in range"
triggers:
  - trigger: time
    at: "21:00:00"
conditions:
  - condition: counter.is_value
    target:
      entity_id: counter.evening_reminders
    options:
      threshold:
        type: between
        value_min:
          number: 1
        value_max:
          number: 3
actions:
  - action: script.turn_on
    target:
      entity_id: script.bedtime_checklist

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the condition you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain conditions or suggest the right one when you describe what you want in plain language.