Skip to content

Commit

Permalink
Added 'camera motion summary' blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinfrlch committed Oct 18, 2024
1 parent 3f9ae95 commit f595b77
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 1 deletion.
140 changes: 140 additions & 0 deletions blueprints/camera_motion_summary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
blueprint:
name: Camera Motion Summary
description: Summarizes camera motion events and sends a notification to your phone
domain: automation
input:
notify_device:
name: Notify Device
description: The device to send the notification to
selector:
device:
integration: mobile_app
camera_entities:
name: Camera Entities
description: List of camera entities to monitor
selector:
entity:
domain: camera
multiple: true
trigger_state:
name: Trigger State
description: The state the camera has to be in to trigger the automation
default: recording
selector:
text:
multiline: false
cooldown:
name: Cooldown
description: Time in minutes to wait before running again
default: 10
selector:
number:
min: 0
max: 60
provider:
name: Provider
description: Configuration to use for the video_analyzer service. See docs for additional information.
selector:
config_entry:
integration: llmvision
model:
name: Model
description: Model to use for the video_analyzer service
default: "gpt-4o-mini"
selector:
text:
multiline: false
message:
name: Prompt
description: Model prompt for the video_analyzer service
default: "Summarize briefly what's happening in the camera feed (one sentence max). Don't describe the scene! If there is a person, describe what they're doing. If nothing is happening, say so."
selector:
text:
multiline: true
duration:
name: Duration
description: How long to record for (in seconds)
default: 5
selector:
number:
min: 1
max: 60
interval:
name: Interval
description: Analyze frames every <interval> seconds
default: 3
selector:
number:
min: 1
max: 60
target_width:
name: Target Width
description: Width in pixels to downscale (uses less tokens)
default: 1280
selector:
number:
min: 512
max: 1920
detail:
name: Detail
description: Detail parameter (OpenAI only)
default: 'high'
selector:
select:
options:
- 'high'
- 'low'
max_tokens:
name: Maximum Tokens
description: Maximum number of tokens to generate
default: 50
selector:
number:
min: 1
max: 100
temperature:
name: Temperature
description: Randomness. Lower is more accurate, higher is more creative
default: 0.1
selector:
number:
min: 0.1
max: 1.0
step: 0.1

variables:
cooldown: !input cooldown

trigger:
platform: state
entity_id: !input camera_entities
to: !input trigger_state

condition:
- condition: template
value_template: >
{{ state_attr(this.entity_id, 'last_triggered') is none or
(now() - state_attr(this.entity_id, 'last_triggered')).total_seconds() / 60 > cooldown }}
action:
- service: llmvision.stream_analyzer
data:
provider: !input provider
model: !input model
message: !input message
image_entity: !input camera_entities
interval: !input interval
duration: !input duration
include_filename: true
target_width: !input target_width
detail: !input detail
max_tokens: !input max_tokens
temperature: !input temperature
response_variable: response

- alias: "Send notification"
domain: mobile_app
type: notify
device_id: !input notify_device
title: 'Motion detected in {{ trigger.entity_id.replace("camera.", "").replace("_", " ")|capitalize }}'
message: "{{ response.response_text }}"
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ blueprint:
message:
name: Prompt
description: Model prompt for the video_analyzer service
default: "Summarize briefly what's happening in the camera feed (one sentence max). Don't describe the scene. If there is a person, describe what they're doing."
default: "Summarize briefly what's happening in the camera feed (one sentence max). Don't describe the scene! If there is a person, describe what they're doing. If nothing is happening, say so."
selector:
text:
multiline: true
Expand Down

0 comments on commit f595b77

Please sign in to comment.