Skip to content

Instantly share code, notes, and snippets.

@mediacutlet
Last active April 20, 2025 15:29
Show Gist options
  • Save mediacutlet/a06a0fef274849bccd383a18184003fe to your computer and use it in GitHub Desktop.
Save mediacutlet/a06a0fef274849bccd383a18184003fe to your computer and use it in GitHub Desktop.
StratoBuilds Security Check Script Example
alias: Security Check
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ security_query == 'General Security Check | Query Everything' }}"
sequence:
- action: blink.trigger_camera
metadata: {}
data: {}
target:
entity_id:
- camera.camera_1
- camera.camera_2
- camera.camera_3
- camera.camera_4
- action: button.press
metadata: {}
data: {}
target:
entity_id:
- button.take_snapshot_1
- button.take_snapshot_2
- button.take_snapshot_3
- delay:
seconds: 20
- action: llmvision.image_analyzer
metadata: {}
data:
include_filename: true
target_width: 1600
detail: high
max_tokens: 200
temperature: 0.7
expose_images: true
provider: LLM Vision OpenAI
model: gpt-4o
image_entity:
- camera.camera_snapshot_1
- camera.camera_snapshot_2
- camera.camera_snapshot_3
- camera.camera_snapshot_4
message: >-
You have been invoked for a Security Check. You are a Home
Automation assistant connected to sensors and systems in a home.
Attached are snapshots from inside and outside the home.
Summarize any security concerns (e.g., potential hazards, people,
animals) while ignoring ordinary details. Your response will be
announced over an audio system, so make it conversational.
response_variable: security_cam_snapshot_summary
- variables:
response:
query_all_motion_sensors: >
{% set sensors = {
'binary_sensor.motion_sensor_1': '',
'binary_sensor.motion_sensor_2': '',
'binary_sensor.motion_sensor_3': '(Outdoors, Front Yard)',
'binary_sensor.motion_sensor_4': '(Outdoors, Backyard)',
'binary_sensor.motion_sensor_5': '',
'binary_sensor.motion_sensor_6': '',
'binary_sensor.motion_sensor_7': '(Foyer)',
'binary_sensor.motion_sensor_8': '(Upstairs)',
'binary_sensor.motion_sensor_9': '(Kitchen)',
'binary_sensor.motion_sensor_10': '(Office)'
} %} {% for sensor, note in sensors.items() %} {{
states[sensor].name if states[sensor] is not none else sensor
}}: {{ 'detected' if states[sensor].state == 'on' else 'clear'
if states[sensor].state == 'off' else 'unknown' }} {{ note }}
|{% endfor %} Only mention sensors detecting motion. No emoji.
Keep it conversational as this will be audibly broadcasted.
query_all_contact_sensors: >
{% set sensors = {
'binary_sensor.contact_sensor_1': '(Front Door)',
'binary_sensor.contact_sensor_2': '(Garage Door)',
'binary_sensor.contact_sensor_3': '(Back Door)',
'binary_sensor.contact_sensor_4': '(Windows)',
'binary_sensor.contact_sensor_5': '(Sliding Door)'
} %} Alarm State: {{
states('alarm_control_panel.home_alarm') | title }} | {%
for sensor, note in sensors.items() %} {{ states[sensor].name
if states[sensor] is not none else sensor }}: {{ 'open' if
states[sensor].state == 'on' else 'closed' if
states[sensor].state == 'off' else 'unknown' }} {{ note }} |
{% endfor %} Only mention doors/windows that are open.
Keep it conversational as this will be audibly broadcasted.
- stop: ""
response_variable: response
alias: Query All Motion Sensors and Camera Snapshot Analysis
- conditions:
- condition: template
value_template: "{{ security_query == 'Security Check | Query Motion and Door Contact Sensors' }}"
sequence:
- delay:
seconds: 2
- variables:
response:
query_all_motion_sensors: >
{% set sensors = {
'binary_sensor.motion_sensor_1': '',
'binary_sensor.motion_sensor_2': '',
'binary_sensor.motion_sensor_3': '(Outdoors, Front Yard)',
'binary_sensor.motion_sensor_4': '(Outdoors, Backyard)',
'binary_sensor.motion_sensor_5': ''
} %} {% for sensor, note in sensors.items() %} {{
states[sensor].name if states[sensor] is not none else sensor
}}: {{ 'detected' if states[sensor].state == 'on' else 'clear'
if states[sensor].state == 'off' else 'unknown' }} {{ note }}
|{% endfor %} Only mention sensors detecting motion.
query_all_contact_sensors: >
{% set sensors = {
'binary_sensor.contact_sensor_1': '(Front Door)',
'binary_sensor.contact_sensor_2': '(Garage Door)',
'binary_sensor.contact_sensor_3': '(Back Door)'
} %} Alarm State: {{
states('alarm_control_panel.home_alarm') | title }} | {%
for sensor, note in sensors.items() %} {{ states[sensor].name
if states[sensor] is not none else sensor }}: {{ 'open' if
states[sensor].state == 'on' else 'closed' if
states[sensor].state == 'off' else 'unknown' }} {{ note }} |
{% endfor %} Only mention open doors/windows.
- stop: ""
response_variable: response
alias: Query All Motion and Contact Sensors
fields:
security_query:
selector:
select:
options:
- General Security Check | Query Everything
- Security Check | Query Motion and Door Contact Sensors
- Security Check | Query Camera Snapshots
multiple: false
description: >-
Select a query to check motion sensors, door/window contact sensors, or
request an AI analysis of recent security camera snapshots.
name: Security Query
required: true
default: General Security Check | Query Everything
description: >-
Use this automation to check motion sensors, contact sensors, and security
camera snapshots for security status updates. The AI-generated analysis
provides a spoken summary over an audio system.
icon: mdi:security-network
mode: parallel
max: 10
@enrutador
Copy link

Hi Very interesting Work , congratulations. Its posible using a local IA with ollama ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment