45 lines
1.8 KiB
YAML
45 lines
1.8 KiB
YAML
alias: "Hallway Camera Motion Snapshot"
|
|
description: "Takes a snapshot when the Hallway Nest camera detects motion, analyzes it with AI, and sends a notification."
|
|
triggers:
|
|
- trigger: event.received
|
|
target:
|
|
entity_id: event.hallway_hallway_camera_motion
|
|
options:
|
|
event_type:
|
|
- camera_motion
|
|
- camera_person
|
|
- camera_sound
|
|
actions:
|
|
- variables:
|
|
snapshot_filename: "hallway_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"
|
|
notification_id: "hallway_motion_{{ now().strftime('%Y%m%d_%H%M%S_%f') }}"
|
|
- action: camera.snapshot
|
|
target:
|
|
entity_id: camera.hallway_hallway_camera
|
|
data:
|
|
filename: "/config/www/{{ snapshot_filename }}"
|
|
- delay:
|
|
seconds: 2
|
|
- action: ai_task.generate_data
|
|
continue_on_error: true
|
|
response_variable: ai_profile
|
|
data:
|
|
task_name: "Hallway Camera Analysis"
|
|
entity_id: ai_task.ollama_ai_task_video
|
|
instructions: "Describe what you see in this image in brief. Focus on any people, objects, or activities. Text needs to be max 240 characters."
|
|
attachments:
|
|
- media_content_id: "media-source://media_source/local/{{ snapshot_filename }}"
|
|
media_content_type: image/jpeg
|
|
- action: notify.notify
|
|
continue_on_error: true
|
|
data:
|
|
title: "Motion Detected - Hallway"
|
|
message: "{{ ai_profile.data if ai_profile is defined and 'data' in ai_profile else 'Motion detected, but the AI Task integration failed to return a response.' }}"
|
|
- action: persistent_notification.create
|
|
data:
|
|
title: "Motion Detected - Hallway"
|
|
message: "{{ ai_profile.data if ai_profile is defined and 'data' in ai_profile else 'Motion detected, but the AI Task integration failed to return a response.' }}\n"
|
|
notification_id: "{{ notification_id }}"
|
|
mode: queued
|
|
max: 10
|