Device
The Device condition checks something that a deviceA device is a model representing a physical or logical unit that contains entities. provides. You select a device, and then select one of the conditions it offers. For example, you can check whether the garage door is open, or whether the alarm is armed.
The conditions you can select depend on the device and its integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more]. For example, a light usually offers Living room light is on and Living room light is off. A sensor can offer a check on its value, and a cover can offer Garage door is open. Not every device offers conditions.
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 By type. Under Generic, select Device.
- You can also search for Device.
- Under Device, select the device you want to check.
- Under Condition, select what you want to check.
- Some conditions show more options, such as Duration, Above, or Below.
- Select Save.
Options in the UI
What to check on the device. The list shows the conditions that this device offers, such as Garage door is open.
Only for some conditions, such as whether a light is on or off. The condition only passes if the device has been in that state for at least this long.
Only for some conditions, such as a sensor value. The condition passes if the value is above this number.
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: device. A device condition refers to the device and the entity by their internal IDs, not by their names. The easiest way to get the YAML is to create the condition in the editor first. Then, on the condition, select Menu
condition: device
device_id: 8a2f5c3e9d1b4f6a7c0e2d4b6f8a1c3e
entity_id: 4b7d9e1f3a5c7e9b1d3f5a7c9e1b3d5f
domain: cover
type: is_open
This passes when the garage door is open.
Options in YAML
In YAML, the options have different names. Device becomes device_id. The Condition you select becomes domain, type, and, for most conditions, entity_id. Some condition types accept more options, such as for, above, or below. These match the extra options in the UI.
The integration or entity domain that provides the condition, such as light, cover, or sensor.
What to check, such as is_on, is_off, or is_open. The available types depend on the domain.
Good to know
- When you create the condition in the editor, it uses internal IDs. It keeps working if you rename the device or change the entity ID. After you change an entity ID, restart Home Assistant or reload your automations, so the condition picks up the new entity ID.
- If you write an entity ID, such as
cover.garage_door, in YAML, update the condition when that entity ID changes. - If you remove the device or its entity, for example, because you replaced the device, the automation stops working. After the next restart or reload, Settings > System > Repairs shows that the automation failed to set up. The error is
Unknown deviceorUnknown entity, with the ID. - For a removed device, the editor shows Editor not available for unknown device. To fix the automation, delete the condition and add it again with the new device.
- If the entity is unavailable or unknown, the condition doesn’t pass. For example, a check whether a light is on or a cover is open fails.
- The State and Numeric state conditions check an entity directly. In YAML, they are easier to read and to share, because they use the entity ID.
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: get a reminder when the garage door is still open
At 22:00, this automation sends a notification, but only if the garage door is open.
-
Trigger: Time
- At time: 22:00:00
-
Condition: Device
- Device: Garage door
- Condition: Garage door is open
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for a garage door reminder
alias: "Garage door reminder"
triggers:
- trigger: time
at: "22:00:00"
conditions:
- condition: device
device_id: 8a2f5c3e9d1b4f6a7c0e2d4b6f8a1c3e
entity_id: 4b7d9e1f3a5c7e9b1d3f5a7c9e1b3d5f
domain: cover
type: is_open
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "The garage door is still open."
Automation: get a notification when a door opens while you’re away
When the back door opens, this automation sends a notification, but only if the alarm is armed away.
-
Trigger: State changed
-
Entity: Back door (
binary_sensor.back_door) - To: Open
-
Entity: Back door (
-
Condition: Device
- Device: Home alarm
- Condition: Home alarm is armed away
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for a notification about the back door
alias: "Back door opened while away"
triggers:
- trigger: state
entity_id: binary_sensor.back_door
to: "on"
conditions:
- condition: device
device_id: 2c4e6a8b0d1f3e5c7a9b1d3f5e7c9a0b
entity_id: 9e1c3a5b7d9f1e3c5a7b9d1f3e5c7a9d
domain: alarm_control_panel
type: is_armed_away
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "The back door was opened while the alarm is armed away."
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.
Related conditions
Explore related conditions:
-
State: Tests if an entity, or one of its attributes, has a specific state.
-
Numeric state: Tests if the number in the state of an entity, or in one of its attributes, is above or below a limit.