Build Advanced Automations with Home APIs on Android
Google for DevelopersJuly 7, 202514 min4,444 views
23 connections·40 entities in this video→Understanding Home API Automations
- 💡 Automations are defined as a set of "if this, then that" statements to control device states based on selected factors.
- 🧩 They are composed of three node types: starters (initial conditions to activate), conditions (constraints to evaluate after triggering), and actions (commands or state updates to perform).
- ⚙️ Nodes can be evaluated in sequential (starter, condition, action) or parallel (multiple actions simultaneously) flows.
- 📝 Developers use a domain-specific language (DSL) to provide these nodes to the automation engine.
Creating an Automation Editor
- 🛠️ An automation editor empowers users to configure devices, commands, and parameters themselves.
- 🔌 Starters are configured by selecting a device, trait, operation, and value, with the app handling preset operations and trait mappings.
- 💡 Actions are defined similarly, specifying device, trait, command, and any necessary parameter values (e.g., brightness level).
- 📝 Automation drafts are prepared in a
DraftViewModel, structuring the automation graph using starter and action variables.
Automation Creation and Validation
- 🚀 The Automation APIs are used to create, delete, and query smart home automations.
- ✅ Automations are validated upon creation; an
is_validfield indicates success, withvalidation_issuesproviding details for invalid automations. - ⚡ Automations can be executed via a starter event or a manual execution API call.
Leveraging the Discovery API
- 🔍 The Discovery API allows querying devices to identify supported attributes and commands.
- 🧩 Discovered candidates (commands, events, trait attributes) can be used to create automation nodes.
- 📱 The app can present discovered actions to the user, pre-populating action nodes in the automation draft based on their selection.
Advanced Automation Examples
- ⏰ Beyond device traits, time-based starters can be used to schedule automations.
- 📢 The Assistant Broadcast trait can be used as an action to announce messages.
- ⏳ Advanced operators like
delayFor(delays commands) andsuppressFor(prevents repeated triggering) enhance automation logic. - 📍 AreaPresenceState can detect if someone is home, enabling automations like locking doors after a certain time.
Knowledge graph40 entities · 23 connections
How they connect
An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.
Hover · drag to explore
40 entities
Chapters7 moments
Key Moments
Transcript52 segments
Full Transcript
Topics15 themes
What’s Discussed
Home APIsAndroid DevelopmentSmart Home AutomationAutomation EditorAutomation DSLStartersConditionsActionsDiscovery APIDevice TraitsSequential FlowsParallel FlowsAssistant BroadcastTime-based TriggersAreaPresenceState
Smart Objects40 · 23 links
Concepts· 22
Products· 15
Company· 1
Media· 1
Location· 1