Or

The Or condition groups several conditions and passes if at least one of them passes. Use it when an automation should continue in more than one situation. For example, the automation turns on the hallway light when the sun is down, or when the hallway is dark during the day.

The conditions in the And if section of an automation must all pass. You can add an Or condition next to them. The automation then continues if all the other conditions pass, and at least one condition inside the Or condition passes.

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 Blocks, then select Or.
    • To add Or inside an And or a Not condition, select Add condition inside that condition, and then select Blocks > Or.
  5. Inside the Or condition, select Add condition, and add the conditions to check.
    • You can add any condition, including other And, Or, and Not conditions.
  6. Select Save.

Options in the UI

The Or condition has no options of its own. It checks the conditions that you add inside it.

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, use condition: or, with the conditions under conditions. A basic example looks like this:

ConditionConditions check whether something is true at that moment, for example, whether a door is closed. You can use them in automations and scripts. If a condition is not met, the actions that come after it in the same sequence do not run. At the top level of an automation or script, this stops the automation or script. [Learn more]
condition: or
conditions:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: state
    entity_id: person.sam
    state: "home"

This passes if Alex or Sam is home, or both.

There is also a shorter form, with the conditions under or:

ConditionConditions check whether something is true at that moment, for example, whether a door is closed. You can use them in automations and scripts. If a condition is not met, the actions that come after it in the same sequence do not run. At the top level of an automation or script, this stops the automation or script. [Learn more]
or:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: state
    entity_id: person.sam
    state: "home"

Options in YAML

condition string Required

The condition type. For this condition, use or. In the shorter form, leave out condition, and use or instead of conditions.

conditions list Required

The conditions to check. At least one of them must pass.

Good to know

  • The conditions are checked in order. As soon as one of them passes, the rest aren’t checked.
  • To check several conditions together as one option, put them in an And condition inside the Or condition. For an example, refer to Automation: turn on the fan when it’s hot, or warm and humid.
  • To pass only if none of the conditions pass, use Not.
  • For a single entity, you don’t always need Or. For example, the State condition passes if the entity has one of several states that you select.

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. In the visual editor, select the UI options listed in the example or paste the YAML code.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual 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: remind you to take a jacket when it’s cold or rainy

At 07:30, this automation sends a reminder to take a jacket, but only if Alex is home, and it’s raining or the outdoor temperature is below 10 °C. The State condition and the Or condition are both in the And if section, so both must pass. Inside the Or condition, one of the two conditions is enough.

  • Trigger: Time
    • At time: 07:30
  • Condition: State
    • Entity: Alex (person.alex)
    • State: Home
  • Condition: Or
    • Condition: State
      • Entity: Home (weather.home)
      • State: Rainy
    • Condition: Numeric state
      • Entity: Outdoor temperature (sensor.outdoor_temperature)
      • Below: 10
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
    • Message: Take a jacket today.
YAML example for the jacket reminder
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Remind me to take a jacket"
triggers:
  - trigger: time
    at: "07:30:00"
conditions:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: or
    conditions:
      - condition: state
        entity_id: weather.home
        state: "rainy"
      - condition: numeric_state
        entity_id: sensor.outdoor_temperature
        below: 10
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "Take a jacket today."

Automation: turn on the hallway light when it’s dark

When motion is detected in the hallway, this automation turns on the hallway light if the sun is down, or if the hallway illuminance is below 20 lx during the day.

  • Trigger: State changed
    • Entity: Hallway motion (binary_sensor.hallway_motion)
    • To: Detected
  • Condition: Or
    • Condition: State
      • Entity: Sun (sun.sun)
      • State: Below horizon
    • Condition: Numeric state
      • Entity: Hallway illuminance (sensor.hallway_illuminance)
      • Below: 20
  • Action: Turn on light
    • Target: Hallway light (light.hallway)
YAML example for the hallway light
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn on hallway light when it's dark"
triggers:
  - trigger: state
    entity_id: binary_sensor.hallway_motion
    to: "on"
conditions:
  - condition: or
    conditions:
      - condition: state
        entity_id: sun.sun
        state: "below_horizon"
      - condition: numeric_state
        entity_id: sensor.hallway_illuminance
        below: 20
actions:
  - action: light.turn_on
    target:
      entity_id: light.hallway

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.

Related conditions

Explore related conditions:

  • And: Tests if all of its conditions pass.