I also needed to take control so I can use my camera binary sensor for person detection.
To solve the API limit, I guess there is a even simpler method:
Configure the automation with:
mode: single
max_exceeded: silent
and add a delay to the action sequence:
delay: 60
Here is the edited automation, be aware, I added some instructions to be mean , also, I’m sending the notification using Discord, so I can see later the images, as HA iOS notifications are ephemeral, and finally I modified the template to ignore no obvious motion as it wasn’t working too good for me.
alias: Camera Snapshot, AI & Notification on Motion
description: ""
triggers:
- entity_id:
- binary_sensor.g4_doorbell_person_detected
to: "on"
trigger: state
actions:
- if:
- condition: []
then:
- repeat:
count: "{{ num_snapshots }}"
sequence:
- target:
entity_id: "{{ camera_device }}"
data:
filename: >-
./www/snapshots/{{ camera_path }}_snapshot{{ repeat.index
}}.jpg
action: camera.snapshot
- delay:
milliseconds: 700
- data:
prompt: "{{ ai_prompt }}"
image_filename: >
{% set snap_count = num_snapshots %} {% set ns =
namespace(images=[]) %} {% for i in range(1, snap_count + 1) %}
{% set image = "./www/snapshots/" ~ camera_path ~ "_snapshot" ~ i ~ ".jpg" %}
{% set ns.images = ns.images + [image] %}
{% endfor %} {{ ns.images }}
response_variable: generated_content
action: google_generative_ai_conversation.generate_content
- choose:
- conditions:
- condition: template
value_template: >-
{{ 'no obvious motion observed' not in
generated_content['text'] | lower }}
sequence:
- action: notify.discord_doorbell_channel
data:
message: ""
data:
embed:
title: "{{ motion_name }}"
description: "{{ generated_content['text'] }}"
images:
- >-
/config/www/snapshots/g4_doorbell_high_resolution_channel_snapshot2.jpg
- delay: 60
variables:
camera_device: camera.g4_doorbell_high
camera_name: "{{ state_attr(camera_device, 'friendly_name') }}"
camera_path: "{{ state_attr(camera_device, 'friendly_name') | lower | replace(' ', '_') }}"
motion_sensor: binary_sensor.g4_doorbell_person_detected
motion_name: "{{ state_attr(motion_sensor, 'friendly_name') }}"
is_ios: true
num_snapshots: 3
snapshot_access_file_path: /local/snapshots/{{ camera_path }}_snapshot1.jpg
ai_prompt: >-
Motion has been detected, compare and very briefly describe what you see in
the following sequence of images from my {{ camera_name }} camera, be very
mean and roast. The answer should in english then followed by the spanish
translation. Do not describe stationary objects or buildings. If you see no
obvious causes of motion, reply with "Camera has detected motion however no
obvious motion observed comparing snapshots".
mode: single
max_exceeded: silent
I have this working, however i would like the words that are sent through on the notification to be also read out on my google speaker. Is there a simple enough way to do this please?
I like the blueprint but had the same issue as a few people above, that nobody was ever in the picture - plus I had a lot of false positives due to the movement of trees, bushes, etc.
I resolved it by triggering off object detection in my Frigate installation: sensor.whatevercam_all_count
Works great for me now and shows the person in the image that’s sent.
I scrolled through this sizable post and apologies if this was already asked, how do I add a specific notification channel to the automation created from this blueprint?
In my other notifications of this severity, I would use this data value:
I took the first 5 and the last line of my example straight out of the - only - file called ai_camera_motion_notification.yaml from the folder called \blueprints\automation\mcinnes01.
No idea why yours would look different - unless you downloaded a previous version of the blueprint that didn’t have these lines (yet), which is hard to imagine because it holds the info for the notification that’s sent to your mobile.
I had to play around with the indentation for a bit since File Editor was complaining. This is what I ended up with that cleared the formatting errors.
But after a new trigger from the camera, the notification Channel is still ‘General’ and not using the new Low channel
This needs to be at one level lower than the data entry above, i.e. two spaces further to the right.
Apologies, my spacing might not have been correct in the example.