AboutBlogContact

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.bedroom

Using 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.kitchen

Then 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_covers

Example 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.hallway

The 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: all

Creating Automations in UI

You don't have to write YAML - Home Assistant has a visual automation editor:

  1. Go to SettingsAutomations & Scenes
  2. Click Create Automation
  3. Choose Create new automation
  4. 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

ScenarioWhere to Configure
Button → Light toggleboneIO click_action
Button → Cover up/downboneIO click_action
Double-click → SceneboneIO double_click_action
Long-press → All lights offboneIO long_click_action
Time-based actionsHome Assistant automation
Sun-based actionsHome Assistant automation
Conditional logicHome Assistant automation
NotificationsHome Assistant automation

Next Steps

  • Dashboards - Create beautiful control panels for your smart home