Skip to content

Automation examples

Chris Brightly edited this page Oct 9, 2026 · 4 revisions

Automation examples

A cookbook of common patterns. Adjust entity ids to match your devices.

Use cases at a glance

  • Security notifications - combine event.motion with a notify action and camera.snapshot to get a push notification with a still image whenever someone approaches, even while you're away.
  • Doorbell-and-announce - when a front-door camera detects a person, announce "Someone is at the door" through a speaker and flash the living-room lights.
  • PTZ patrol - step through a sequence of pan/tilt positions on a schedule or when a zone becomes occupied.
  • Occupancy-triggered lighting - use binary_sensor.occupancy to turn on outdoor lights when the camera detects presence, off a fixed time after it clears.
  • Recording review in HA - browse and replay cloud clips in the Media panel (see Cloud recordings).

Motion alert with a snapshot

Send a mobile notification with a camera still when motion is detected.

alias: Camera motion alert
triggers:
  - trigger: state
    entity_id: binary_sensor.front_door_occupancy
    to: "on"
actions:
  - action: camera.snapshot
    target:
      entity_id: camera.front_door
    data:
      filename: /config/www/snapshots/front_door_latest.jpg
  - action: notify.mobile_app_my_phone
    data:
      title: Motion detected
      message: Someone is at the front door.
      data:
        image: /local/snapshots/front_door_latest.jpg

Floodlight on for 60 seconds when a person is detected

The event.motion entity fires with an event_type of person for person detections and motion for general motion. Filter on person to avoid triggering on animals or branches.

alias: Floodlight on person
triggers:
  - trigger: event
    event_type: state_changed
    event_data:
      entity_id: event.backyard_motion
actions:
  - condition: template
    value_template: >
      {{ trigger.event.data.new_state.attributes.event_type == 'person' }}
  - action: light.turn_on
    target:
      entity_id: light.backyard_floodlight
  - delay:
      seconds: 60
  - action: light.turn_off
    target:
      entity_id: light.backyard_floodlight

PTZ preset patrol

Step through positions in sequence. Each button.press nudges the camera; adjust the delay to control dwell time. The camera must be streaming for PTZ commands to reach it - include a camera_view: live card on a dashboard to keep the session alive, or start the stream with a camera.turn_on action before the sequence.

alias: PTZ patrol
triggers:
  - trigger: time_pattern
    minutes: /30
actions:
  - action: button.press
    target:
      entity_id: button.outdoor_ptz_ptz_left
  - delay:
      seconds: 5
  - action: button.press
    target:
      entity_id: button.outdoor_ptz_ptz_stop
  - delay:
      seconds: 10
  - action: button.press
    target:
      entity_id: button.outdoor_ptz_ptz_right
  - delay:
      seconds: 5
  - action: button.press
    target:
      entity_id: button.outdoor_ptz_ptz_stop

Doorbell announce through the camera speaker

alias: Announce at the door
triggers:
  - trigger: state
    entity_id: binary_sensor.front_door_occupancy
    to: "on"
actions:
  - action: aidot.talk
    target:
      entity_id: camera.front_door
    data:
      media: "media-source://media_source/local/please_wait.mp3"
      max_seconds: 10

PTZ requires an active stream. If an automation runs it against an idle camera, start the stream first (camera.turn_on) and allow for the cold-start delay described in Cameras. aidot.talk does not need one - it reuses the live session when there is one and otherwise opens its own temporary session - but an idle camera still pays that cold start before the clip plays.

Clone this wiki locally