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
- User-friendly: Users select devices instead of entity IDs
- Discovery: Automations are suggested based on available devices
- Type-safe: Structured configuration prevents errors
- 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_pressinstead ofbtn_spmotion_detectedinstead ofmotion