I’m doing a cool thing that used to work without fail, but increasingly I have been running in to a weird problem. I guess I am trying to figure out not just how to fix the problem but also learn a bit more about how home assistant automations work. Here’s what I am doing:
Trigger: Garage door changes state to “closed”
Actions:
- camera.snapshot image capture of the crappy old ip cam pointed at the car bays and garage door (static filename, so it overwrites the old photo)
- send image to Google AI asking it to describe how many cars are in the picture and whether the garage door is open or closed
- send message to my phone with the AI response plus the photo so I can see for myself
- send message to my wife’s phone with the same content that I sent myself.
The problem is that I am often getting an old photo. For example, I drive off, close the garage door, and the message we receive is that there are two cars. The attached photo has two cars. I return, park the car and close the garage door, it sends me a photo of only one car and a description that says the same.
It used to work all the time, now it rarely sends a correct photo.
So I added a 15 second delay between camera.snapshot and the Google AI API call, no improvement.
Questions:
- Does HA run actions in parallel? That is, does the camera.snapshot need to terminate successfully before the next action begins? When I look through the trace, I can not see the time that an action finishes or exactly when the next action begins. Just the start time and the completion time.
- Looking in /config/home-assistant.log shows very little - should I change the log level to something more verbose, or should I look elsewhere?
- Does HA cache images somewhere?
- Where would I look to find a log entry showing me the start time and end time of the camera.snapshot file operation? Could that be taking a long time to complete?
- Unrelated to this issue but an additional major annoyance in the below code: in half my script I have to specify /config/www for things to work, and the other half I have to specify /local for it to work. Is that as designed?
Thank you in advance! Here’s a copy of my automation in case it helps.
- id: ‘123’
alias: Garage Status Description
description: ‘’
trigger:- platform: state
entity_id:- cover.garage_door_1_msg100_main_channel
from:
to: closed
for:
hours: 0
minutes: 0
seconds: 15
condition:
action:
- cover.garage_door_1_msg100_main_channel
- service: camera.snapshot
metadata: {}
data:
filename: /config/www/garage-camera/garage-static.jpg
target:
device_id: 123456 - delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0 - service: google_generative_ai_conversation.generate_content
data:
image_filename: /config/www/garage-camera/garage-static.jpg
prompt: Describe what you see in this image from my garage camera. Your message
needs to be short to fit in a phone notification. Include whether the garage
door is open and the number of cars. Be friendly and polite.
response_variable: geminitext - service: notify.mobile_app_hogphone
metadata: {}
data:
data:
image: /local/garage-camera/garage-static.jpg
message: ‘{{ geminitext.text }}’ - service: notify.mobile_app_iphone13_hb
metadata: {}
data:
data:
image: /local/garage-camera/garage-static.jpg
message: ‘{{ geminitext.text }}’
enabled: true
mode: single
- platform: state