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:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the And if section, select Add condition.
- 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.
- 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.
- 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:
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:
and:
- condition: state
entity_id: person.alex
state: "home"
- condition: numeric_state
entity_id: sensor.living_room_temperature
below: 20
Options in YAML
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.
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)
-
Entity: Living room temperature (
-
Condition: Or
-
Condition: Numeric state
-
Entity: Living room temperature (
sensor.living_room_temperature) - Above: 26
-
Entity: Living room temperature (
-
Condition: And
-
Condition: Numeric state
-
Entity: Living room temperature (
sensor.living_room_temperature) - Above: 24
-
Entity: Living room temperature (
-
Condition: Numeric state
-
Entity: Living room humidity (
sensor.living_room_humidity) - Above: 70
-
Entity: Living room humidity (
-
Condition: Numeric state
-
Condition: Numeric state
-
Action: Turn on fan
-
Target: Living room fan (
fan.living_room)
-
Target: Living room fan (
YAML example for turning on the fan
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
-
Entity: Front door (
-
Condition: State
-
Entity: Back door (
lock.back_door) - State: Locked
-
Entity: Back door (
-
Condition: State
-
Condition: And
-
Action: Send a notification message
-
Target: My Device (
notify.my_device) - Message: Not all doors are locked.
-
Target: My Device (
YAML example for the door reminder
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.
AI assistants like ChatGPT or Claude can also explain conditions or suggest the right one when you describe what you want in plain language.