Device
The Device trigger starts an automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more] when something happens to a deviceA device is a model representing a physical or logical unit that contains entities., such as a button press on a remote. You select a device first, and then select one of the triggers that the device offers, such as “Turn on” pressed. The list comes from the device’s integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more], and not every device offers triggers.
For most changes, such as a door opening or a light turning on, use a purpose-specific trigger instead, such as Door opened or Light turned on. Use the Device trigger for button presses and other events that no other trigger covers.
Choosing between the Device trigger and other triggers
Use the Device trigger for button presses and other eventsEvery time something happens in Home Assistant, an event is fired. Different types of events are fired when, for example, an entity’s state changes, an action such as light.turn_on is performed, or Home Assistant starts. All entities produce state change events. Every time the state or the attributes of an entity change, a state change event is produced. Events can be used to trigger automations. For example, you can trigger an automation to turn on a speaker in a room when a light in that room turns on. [Learn more] that have no entity.
For changes that other triggers also cover, use those triggers instead, such as Door opened or Temperature crossed threshold. They’re easier to set up and to read. If you target an entity or an area instead of a device, they’re also easier to share in YAML, and they keep working when you replace the device, as long as the new entity gets the same entity ID or is in the same area.
How the Device trigger differs from other triggers
Most triggers are named after what you want to react to, such as Door opened. The Device trigger starts from the device and shows the triggers that its integration offers for it. They fall into two groups:
- Many of them react to changes that a purpose-specific trigger also covers, such as a light turning on. For these, use the purpose-specific trigger instead.
- Some devices, such as some Zigbee remotes, report button presses without an entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more]. The Device trigger is the only trigger that lists these button presses, so you can select them. Otherwise, you’d need to enter the event details yourself in a Manual event received trigger.
Two ways to start from a device
The Add trigger dialog has two tabs, By type and By target. Both let you start from a device, but only By type gets you a Device trigger. The steps are in Adding the Device trigger to an automation.
Under By target, you can select a device and then pick from the triggers that work with its entities. You get a trigger, such as Door opened, with the device as its target. It isn’t a Device trigger.
The two lists often have triggers that react to the same thing, such as Door opened and Front door opened. Button presses without an entity only show up in the Device trigger.
To tell them apart, look at the name. Many Device triggers include the name of your entity, such as Front door opened. The other triggers have a general name, such as Door opened.
Using this trigger from the user interface
If you prefer building automations visually, Home Assistant walks you through this trigger step by step. You pick what to watch, tweak a few options, and save. No YAML knowledge required.
Adding the Device trigger to an automation
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the When section, select Add trigger.
- Select By type. Under Generic, select Device.
- You can also search for Device.
- Under Device, select the device you want to watch.
- Under Trigger, select what should start the automation.
- Some triggers show more options, such as Duration, Above, or Below.
- Select Save.
Options in the UI
What should start the automation. The list shows the triggers that this device offers, such as Living room light turned on or “Turn on” pressed.
Only for some triggers, such as a light turning on or off. The trigger only reacts after the device has been in the new state for this long. By default, the trigger reacts right away.
Only for some triggers, such as a sensor value. The trigger reacts when the value rises above this number. For a sensor, set at least one of Above or Below. No default.
Only for some triggers, such as a sensor value. The trigger reacts when the value drops below this number. For a sensor, set at least one of Above or Below. No default.
Only for some triggers, such as an option change on a select entity. The state to change from. If you leave it empty, the trigger reacts to a change from any state.
Only for some triggers. The new state to react to, such as Heat. Required for some triggers, such as Thermostat HVAC mode changed. Optional for others, such as an option change on a select entity.
Using this trigger 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 YAMLYAML is a human-readable data serialization language. It is used to store and transmit data in a structured format. In Home Assistant, YAML is used for configuration, for example in the configuration.yaml or automations.yaml files. [Learn more], use trigger: device. A Device trigger refers to the device, and often an entity, by their internal IDs, not by their names. The easiest way to get the YAML is to create the trigger in the editor first. Then, on the trigger, select Menu
trigger: device
device_id: 3f6a9c2e1b4d7f8a0c5e2b9d6a3f1c7e
entity_id: 7c1e4a9b2d5f8e3a6c0b9d2f5a8e1c4b
domain: light
type: turned_on
This trigger reacts when the light of this device turns on.
Options in YAML
In YAML, the options have different names. Device becomes device_id. The Trigger you select becomes domain, type, and, depending on the trigger, entity_id or subtype. Duration, Above, Below, From, To, and Zone become for, above, below, from, to, and zone.
The following list shows the common options. Some integrations add their own options. For example, some Z-Wave triggers also need command_class. To get the exact options for your device, create the trigger in the editor and copy its YAML.
The integration or entity domain that provides the trigger, such as light, sensor, or zha.
What should start the automation, such as turned_on, turned_off, or remote_button_short_press. The available types depend on the domain and the device.
Required for triggers based on an entity. The entity of the device to watch. The editor stores the entity’s internal ID. An entity ID, such as light.living_room, also works.
Only for some triggers. Narrows down the type, such as which button was pressed.
Only for some triggers. How long the device must stay in the new state before the trigger reacts. Use a mapping with days, hours, minutes, seconds, or milliseconds, such as minutes: 30. A time string such as "00:30:00" doesn’t work here. By default, the trigger reacts right away.
Only for some triggers. The trigger reacts when the value rises above this number. For a sensor, set at least one of above or below. No default.
Only for some triggers. The trigger reacts when the value drops below this number. For a sensor, set at least one of above or below. No default.
Only for some triggers, such as an option change on a select entity. The state to change from. If you leave it out, the trigger reacts to a change from any state.
Only for some triggers. The new state to react to, such as heat. Required for some triggers, such as an HVAC mode change on a thermostat. Optional for others, such as an option change on a select entity.
Good to know
- When you create the trigger in the editor, it uses internal IDs, so you can rename the device or change the entity ID without editing the trigger. After you change an entity ID, restart Home Assistant or reloadApplies the changes made to Home Assistant configuration files. Changes are normally automatically updated. However, changes made outside of the front end will not be reflected in Home Assistant and require a reload. your automations. The trigger then picks up the new entity ID automatically.
- If you write an entity ID, such as
light.living_room, in YAML, update the trigger when that entity ID changes. - If you remove the device, for example, because you swapped it for a new physical device, the automation stops working. After the next restart or reload, Settings > System > Repairs shows that the automation failed to set up, with an
Unknown deviceerror. If you remove only the entity, the error isUnknown entity. If you wrote the entity ID in YAML, such aslight.living_room, no error is shown. The trigger stays set up but doesn’t react until you update it. - For a removed device, the editor shows Editor not available for unknown device. To fix the automation, delete the trigger and add it again with the new device.
- This is different from Home Assistant replacing a device with one or more new devices, for example, when it splits one device into separate devices per integration. In that case, the trigger keeps working. For a trigger that an integration provides, such as a button press on a remote, Home Assistant uses the replacement device from that integration. For other triggers, such as a light turning on, Home Assistant keeps using the old device. The editor still opens and, under Device, shows which device replaced the old one. Selecting that device and saving is optional. It updates the trigger to refer to the new device directly.
- If you use the Duration (
for) option, a restart or reload cancels the running timer. The trigger only reacts after the device changes to the new state again and stays there for the full duration.
Try it yourself
Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation. Then do what you selected under Trigger, such as pressing the button on your remote, to see the trigger react.
More examples
Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example when they are available, 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 lights with a remote button
When you press the “Turn on” button on a Zigbee remote, this automation turns on the living room lights.
-
Trigger: Device
- Device: Living room remote
- Trigger: “Turn on” pressed
-
Action: Turn on light
- Target: Living room (area)
YAML example for a remote button
alias: "Turn on living room lights with the remote"
triggers:
- trigger: device
device_id: 5b8e1d4a7c0f3e6b9d2a5c8f1e4b7d0a
domain: zha
type: remote_button_short_press
subtype: turn_on
actions:
- action: light.turn_on
target:
area_id: living_room
Automation: turn off all lights on a floor with a long press
When you press and hold the “Turn off” button on a Zigbee remote, this automation turns off all lights on the ground floor.
-
Trigger: Device
- Device: Living room remote
- Trigger: “Turn off” continuously pressed
-
Action: Turn off light
- Target: Ground floor (floor)
YAML example for a long press
alias: "Turn off the ground floor lights with the remote"
triggers:
- trigger: device
device_id: 5b8e1d4a7c0f3e6b9d2a5c8f1e4b7d0a
domain: zha
type: remote_button_long_press
subtype: turn_off
actions:
- action: light.turn_off
target:
floor_id: ground_floor
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the trigger 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 triggers or suggest the right one when you describe what you want in plain language.
Related triggers
Explore related triggers:
-
State changed: Triggers when the state or an attribute changes.
-
Numeric state crossed threshold: Triggers when a numeric value crosses a threshold.
-
Manual event received: Triggers when an event is fired on the Home Assistant event bus.