I have a whole bunch of automations that use the deprecated google_generative_ai_conversation.generate_content action… I want to switch over to ai_task.generate_data action, but I`m confused how to attach a file to it like I did before. Few of my automations use this type of action. How can I substitute for the new way ?
action: google_generative_ai_conversation.generate_content
metadata: {}
data:
filenames: /config/www/proxy/XXXXXXX.jpeg
prompt: >-
Very briefly describe what you see in this image from my XXXXX
camera.Don’t describe stationary objects or buildings.
response_variable: doorbellimagechanged
continue_on_error: true
I`m a little confused on how to add the /config/www/proxy/XXXXXXX.jpeg file, I looked at the docs and it seems only media is able to attach from the build in media HA interface ?
If your image is in /config/www/proxy/…, map that folder (or the whole /config/www) under media_dirs:
# configuration.yaml
homeassistant:
media_dirs:
local: /media # keep default
www: /config/www # exposes ALL of /config/www
# or, if you prefer just the proxy subfolder:
# proxy: /config/www/proxy
Then Restart Home Assistant (or Developer Tools → YAML → Reload core configuration if offered). This makes your folder appear in the Media Browser and gives it a media-source name (www or proxy). Home Assistant
- action: ai_task.generate_data
response_variable: doorbellimagechanged
data:
task_name: "doorbell snapshot description"
instructions: >
Very briefly describe what you see in this image.
Focus on people/vehicles; skip background objects.
attachments:
# If you mapped "www: /config/www"
- media_content_id: media-source://media_source/www/proxy/XXXXXXX.jpeg
media_content_type: image/jpeg
# If you mapped "proxy: /config/www/proxy" instead, use:
# - media_content_id: media-source://media_source/proxy/XXXXXXX.jpeg
# media_content_type: image/jpeg
However id simply adjust my automation to snap a picture directly from the camera as its easy to do now. (Correct me if i wrong you use to capture snapshot then save it to www under the same file name every time then reference that in google generative ai?)
wow you are great ! Yes I take a snapshot and save it to the folder and then reference it in the AI task. I did see that you can take a snapshot directly from the camera using media now, but I want to send the same original snapshot via notification and email, does taking the snapshot from the ai task will save it somewhere and I can reference it in the email/notificaion ?