And

The And condition groups several conditions and passes only if all of them pass. Use it inside an Or or a Not condition. For example, the automation continues if it’s very hot, or if it’s warm and humid at the same time.

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

Options in the UI

The And 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: and, 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: and
conditions:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: numeric_state
    entity_id: sensor.living_room_temperature
    below: 20

This passes if Alex is home and the living room temperature is below 20 °C.

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

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]
and:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: numeric_state
    entity_id: sensor.living_room_temperature
    below: 20

Options in YAML

condition string Required

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

conditions list Required

The conditions that must all pass.

Good to know

  • The conditions are checked in order. As soon as one of them doesn’t pass, the rest aren’t checked.
  • The conditions in the And if section of an automation, and in building blocks like If-then, already must all pass. You don’t need an And condition there.
  • To pass if at least one condition passes, use Or. To pass if none of them pass, use Not.

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: turn on the fan when it’s hot, or warm and humid

When the living room temperature or humidity changes, this automation turns on the fan if the temperature is above 26 °C. It also turns on the fan if the temperature is above 24 °C and the humidity is above 70% at the same time.

  • Trigger: State changed
    • Entity: Living room temperature (sensor.living_room_temperature), Living room humidity (sensor.living_room_humidity)
  • Condition: Or
    • Condition: Numeric state
      • Entity: Living room temperature (sensor.living_room_temperature)
      • Above: 26
    • Condition: And
      • Condition: Numeric state
        • Entity: Living room temperature (sensor.living_room_temperature)
        • Above: 24
      • Condition: Numeric state
        • Entity: Living room humidity (sensor.living_room_humidity)
        • Above: 70
  • Action: Turn on fan
    • Target: Living room fan (fan.living_room)
YAML example for turning on the fan
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn on fan when hot, or warm and humid"
triggers:
  - trigger: state
    entity_id:
      - sensor.living_room_temperature
      - sensor.living_room_humidity
conditions:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.living_room_temperature
        above: 26
      - condition: and
        conditions:
          - condition: numeric_state
            entity_id: sensor.living_room_temperature
            above: 24
          - condition: numeric_state
            entity_id: sensor.living_room_humidity
            above: 70
actions:
  - action: fan.turn_on
    target:
      entity_id: fan.living_room

Automation: send a reminder at night when not all doors are locked

At 22:00, this automation sends a reminder if the front door or the back door isn’t locked. A Not condition with the two doors directly in it would only pass if neither door is locked. With an And condition inside the Not condition, it passes as soon as one door isn’t locked.

  • Trigger: Time: 22:00
  • Condition: Not
    • Condition: And
      • Condition: State
        • Entity: Front door (lock.front_door)
        • State: Locked
      • Condition: State
        • Entity: Back door (lock.back_door)
        • State: Locked
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
    • Message: Not all doors are locked.
YAML example for the door reminder
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Remind me when not all doors are locked"
triggers:
  - trigger: time
    at: "22:00:00"
conditions:
  - condition: not
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: lock.front_door
            state: "locked"
          - condition: state
            entity_id: lock.back_door
            state: "locked"
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "Not all doors are locked."

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.