Not

The Not condition groups one or more conditions and passes only if none of them pass. Use it when an automation should not continue in a certain situation. For example, the automation sends a notification when a door opens, but only if nobody is home.

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

Options in the UI

The Not 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: not, 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: not
conditions:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: state
    entity_id: alarm_control_panel.home_alarm
    state: "disarmed"

This passes if Alex isn’t home, and the alarm isn’t disarmed.

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

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]
not:
  - condition: state
    entity_id: person.alex
    state: "home"
  - condition: state
    entity_id: alarm_control_panel.home_alarm
    state: "disarmed"

Options in YAML

condition string Required

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

conditions list Required

The conditions that must not pass. If one of them passes, the Not condition doesn’t pass.

Good to know

  • With several conditions, Not only passes if none of them pass. To pass if at least one of them doesn’t pass, put them in an And condition inside the Not condition. For an example, refer to Automation: send a reminder at night when not all doors are locked.
  • The conditions are checked in order. As soon as one of them passes, the rest aren’t checked.
  • If an entity usually only has two states, like a light, you often don’t need Not. For example, to check that a light is off, use a State condition with the state Off. The difference: Not with the state On also passes when the light is unavailable (unavailable) or unknown (unknown).

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: send a notification when a door opens and nobody is home

When the front door opens, this automation sends a notification, but only if neither Alex nor Sam is home.

  • Trigger: State changed
    • Entity: Front door (binary_sensor.front_door)
    • To: Open
  • Condition: Not
    • Condition: State
      • Entity: Alex (person.alex)
      • State: Home
    • Condition: State
      • Entity: Sam (person.sam)
      • State: Home
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
    • Message: The front door opened while nobody is home.
YAML example for the door notification
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Notify when the door opens and nobody is home"
triggers:
  - trigger: state
    entity_id: binary_sensor.front_door
    to: "on"
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: person.alex
        state: "home"
      - condition: state
        entity_id: person.sam
        state: "home"
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "The front door opened while nobody is home."

Automation: turn off the living room lights at night, unless the TV is playing

At 23:00, this automation turns off the living room lights, but not while the TV is playing.

  • Trigger: Time
    • At time: 23:00
  • Condition: Not
    • Condition: State
      • Entity: Living room TV (media_player.living_room_tv)
      • State: Playing
  • Action: Turn off light
    • Target: Living room lights (light.living_room)
YAML example for turning off the living room lights
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn off living room lights unless the TV is playing"
triggers:
  - trigger: time
    at: "23:00:00"
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: media_player.living_room_tv
        state: "playing"
actions:
  - action: light.turn_off
    target:
      entity_id: light.living_room

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.

  • Or: Tests if at least one of its conditions passes.