Skip to main content
Device automation allows users to create automations based on device events, states, and actions without needing to know entity IDs. This guide covers how to implement device triggers, conditions, and actions for your integration.

Overview

Device automation consists of three components:
  • Triggers: Events that start an automation (e.g., “button pressed”)
  • Conditions: States that must be true for automation to run (e.g., “light is on”)
  • Actions: Things the automation can do (e.g., “turn on light”)

Benefits of Device Automation

  1. User-friendly: Users select devices instead of entity IDs
  2. Discovery: Automations are suggested based on available devices
  3. Type-safe: Structured configuration prevents errors
  4. UI-first: Fully integrated with the automation UI

File Structure

Device automation implementations use separate files:

Implementing Device Triggers

Device triggers fire when specific events occur on a device.

Basic Trigger Implementation

device_trigger.py

Firing Device Triggers

In your integration code, fire events when triggers occur:
__init__.py

Trigger Types Examples

Common trigger types:

Implementing Device Conditions

Device conditions check device state in automations.

Basic Condition Implementation

device_condition.py

Implementing Device Actions

Device actions perform operations in automations.

Basic Action Implementation

device_action.py

Advanced: Entity-Based Device Automation

For simple entity-based device automation, you can use the built-in helpers:
device_trigger.py

Translations

Provide translations for device automation UI:
strings.json

Testing Device Automation

Test your device automation implementation:
test_device_trigger.py

Best Practices

Use Clear Type Names

Choose descriptive trigger/condition/action types:
  • button_short_press instead of btn_sp
  • motion_detected instead of motion

Provide Good Translations

Translations should be clear and use entity names when available:

Handle Entity Registry

Always check if entities exist and handle missing entities gracefully. If a device supports multiple similar actions, group them logically.

Test Thoroughly

Write tests for all trigger types, conditions, and actions.

Common Patterns

Multi-Button Devices

For devices with multiple buttons:

Brightness/Value Actions

For actions that accept values:

Next Steps