First Automation
This guide will help you create your first Home Assistant automations. We'll focus on scenarios that require Home Assistant - things that boneIO cannot do internally.
Remember: Simple actions like "button toggles light" or "button controls cover" should be configured in boneIO. They work faster and remain functional even when Home Assistant is offline.
Automation Anatomy
Every Home Assistant automation consists of three parts:
automation:
- alias: "Automation Name"
trigger:
# WHEN should it run?
condition:
# ONLY IF these conditions are met (optional)
action:
# WHAT should happen?Example 1: Close Covers at Sunset
This automation closes all covers 30 minutes after sunset - something boneIO cannot do alone.
automation:
- alias: "Close covers at sunset"
trigger:
- platform: sun
event: sunset
offset: "+00:30:00"
action:
- service: cover.close_cover
target:
entity_id: cover.living_room
- service: cover.close_cover
target:
entity_id: cover.bedroomUsing Cover Groups
If you have many covers, create a group first:
# In configuration.yaml
cover:
- platform: group
name: "All Covers"
entities:
- cover.living_room
- cover.bedroom
- cover.kitchenThen use it in automation:
automation:
- alias: "Close all covers at sunset"
trigger:
- platform: sun
event: sunset
offset: "+00:30:00"
action:
- service: cover.close_cover
target:
entity_id: cover.all_coversExample 2: Turn On Light When Motion Detected (Only When Dark)
This requires conditional logic - turn on light only if it's dark outside.
automation:
- alias: "Hallway motion light"
trigger:
- platform: state
entity_id: binary_sensor.hallway_motion
to: "on"
condition:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 5
action:
- service: light.turn_on
target:
entity_id: light.hallway
- delay:
minutes: 3
- service: light.turn_off
target:
entity_id: light.hallwayThe delay in this automation blocks further triggers. For better behavior, use a separate automation with wait_for_trigger or use the motion_light blueprint.
Example 3: Notification When Gate Open Too Long
Send a phone notification if the gate has been open for more than 10 minutes.
automation:
- alias: "Gate open too long notification"
trigger:
- platform: state
entity_id: binary_sensor.gate
to: "on"
for:
minutes: 10
action:
- service: notify.mobile_app_your_phone
data:
title: "Gate Alert"
message: "Gate has been open for 10 minutes!"
data:
tag: "gate-alert"Example 4: Turn Off All Lights When Leaving Home
Use person tracking to automate actions when everyone leaves.
automation:
- alias: "Turn off lights when leaving"
trigger:
- platform: state
entity_id: person.john
from: "home"
condition:
- condition: state
entity_id: person.jane
state: "not_home"
action:
- service: light.turn_off
target:
entity_id: allCreating Automations in UI
You don't have to write YAML - Home Assistant has a visual automation editor:
- Go to Settings → Automations & Scenes
- Click Create Automation
- Choose Create new automation
- Add triggers, conditions, and actions using the visual editor
The UI editor is great for simple automations. For complex logic or templates, YAML gives you more control.
Tips for boneIO Users
| Scenario | Where to Configure |
|---|---|
| Button → Light toggle | boneIO click_action |
| Button → Cover up/down | boneIO click_action |
| Double-click → Scene | boneIO double_click_action |
| Long-press → All lights off | boneIO long_click_action |
| Time-based actions | Home Assistant automation |
| Sun-based actions | Home Assistant automation |
| Conditional logic | Home Assistant automation |
| Notifications | Home Assistant automation |
Next Steps
- Dashboards - Create beautiful control panels for your smart home