Generative AI camera snapshot notification

I’ve created a camera snapshot notification blueprint based around code-snippets/README.md at main · AdamGit69/code-snippets · GitHub

It allows you to select the following options:

  • Camera
  • Motion entity
  • Device to send a notification to
  • Number of snapshots to take
  • Change the AI prompt

It then uses Google Generative AI to comment on what changes its observed between the snapshot with 500ms delay between each image.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

image

9 Likes

Hi Andy McInnes,

Very nice design, sir.
2 things however.
One, people will be wanting the fancy my-link thing from you to load this. Please consider setting this up for them.
Create a link – My Home Assistant.
Two, I would be interested in seeing if this would work with Ollama locally as opposed to going to the cloud. Do you have the ability to test/code that?
I would consider trying to do that but you have the original and expertise. I would have to use yours and get it running and understand it before I could plug my Ollama instance in and see how it does.

1 Like

I haven’t tried anything with Ollama yet, but it would be interesting to have completely local, not least to mention I’d like to do a lot of AI detection and I’m pretty sure I’ll soon hit the free usage cap. Do you have any details on a Ollama setup in HA?

I personally set Ollama up on a Linux machine with a GPU. Lots of ways to do that, need to search to fit your hardware.
Then there id the Ollama integration to make an assistant.
Ollama - Home Assistant.

I am currently using it as a local ChatGPT replacement to stay local, not using the HA connection (yet). Haven’t had the time to spend to figure it out with Summer going on.

I’ve found an Ollama addon I’ve installed, you wouldn’t know which model would be well suited for generative image analysis and maybe if such a thing exists, also good for home assistant in general?

There is the addon, but then the HA server has to have the big video card (GPU). Personally I just loaded Ollama on a gaming machine that sits idle most of the time and then the Ollama integration I mentioned can talk to that and be an assistant.

I’ve tried a few models llama3 and llava-llama3 the first just kept timing out and the latter gave me this:

“Sorry, I had a problem talking to the Ollama server: llava-llama3:latest does not support tools”

My home assistant box is only a mini itx with an i5 integrated graphics and 16gb ram, so it’s not really got the grunt I think these models need.

Integrated Graphics are going to struggle. It needs a GPU.

When I do trace, I get error at the AI step: “Error: Error generating content: 404 Gemini 1.0 Pro Vision has been deprecated on July 12, 2024. Consider switching to different model, for example gemini-1.5-flash.”

I tried with the same free tier account in a browser and I do have access with genini-1.5-flash.

I have set model as “models/gemini-1.5-flash-latest” in Google Generative AI Conversation and has reloaded the integration several times. Is there anywhere else that I need to update?

I struggle with the documentation file regarding the versions and updates, would be great if there was only one off readme file.
Thank you tho.

Error: Error generating content: 404 Gemini 1.0 Pro Vision has been deprecated on July 12, 2024. Consider switching to different model, for example gemini-1.5-flash.

I am still blocked on this version mismatch thing. Everything else looks good, the snapshots are being taken, HA reloaded several times, in Gemini webpage it works great.

I tried to add model: 'models/gemini-1.5-pro-002' in the blueprint under data for service: google_generative_ai_conversation.generate_content but I don’t think that action allows that parameter. The only place I can find to change model is in the integration itself and I have already changed there.

What am I missing?

Did you figure this out yet? I’m having the same problem.

ịm have issue, have snapshot only show 1 picture but content correct with motion :frowning:

Hi @mcinnes01

Nice work, I’ve had a play and added some extra triggers so I can use multiple sensors to fire the camera - e.g. Camera motion plus a sensor in my mailbox that the camera does not always record on when there is mail delivered, not it does.

bugfix ?

I think I’ve found a bit of code that needs fixing, as the number of images to generate is not dynamically added for the AI push.

e.g. current code:
image_filename: "{% set snap_count = 3 %}

will send correct number when updated to use variable.
image_filename: "{% set snap_count = num_snapshots %}

Thanks for the headstart on this, I’m new to blueprints and this is my first one I’ve cloned and modded.

I’m stuck on identifying which trigger (motion sensor) fired as I’d like to use that in the push description as extra info, i.e. update ‘motion_name’ in your code based on the trigger that fired. I’m sure I will work it out, but any tips appreciated.

2 Likes

Brilliant work @mcinnes01,
I’ve just imported your Blueprint and it works like a charm.

Great work! Is it possible for you to add the option to choose title for the message? I can do that when taking control of the blueprint but I guess it would be more helpful for people if it was an option.
Also, is it possible to add the option not to return a message if it doesn’t detect any differences?
Thanks.

1 Like

Great work, I was sturggling with the original code.
Has anybody gotten this to work with blink Cameras? It is just using my permanent thumbnail for each camera instead of a live camera snapshot.

How do I make this work with Ollama, I have Ollama already setup with HA.

can you help me and give me line by line instructions?

Can this be altered to use a binary sensor rather than motion detection for example when “binary_sensor.front_door_g4_doorbell_pro_person_detected” changes to on?

I’d like to only get this if a person is detected not for every car that drives down the street.