I’m running the 0.91.2 docker container image. I have a couple of cameras that are “stream” capable, and am trying to utilize that as part of an automation. What I’m trying to do is capture a video clip in an automation, and then send that clip in a notification using slack. And other foolishness… My automation looks like this:
- alias: doorbell fired
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.doorbell_button
to: 'on'
action:
- service: logbook.log
data_template:
name: Front Porch Doorbell
message: "Front doorbell action invoked at {{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
entity_id: input_boolean.doorbell_button
domain: input_boolean
- service: camera.snapshot
data:
entity_id: camera.cam5
filename: "/config/www/snaps/cam5.jpg"
- service: camera.snapshot
data:
entity_id: camera.cam6
filename: "/config/www/snaps/cam6.jpg"
- service: camera.record
data:
entity_id: camera.cam6
filename: /config/www/snaps/cam6.mp4
duration: 15
lookback: 10
- service: image_processing.scan
entity_id: image_processing.tensorflow_cam6
- delay: '00:00:15'
- service: notify.slack
data:
message: "Doorbell Video"
title: "hass"
target:
- "#home"
data:
file:
path: "/config/www/snaps/cam6.mp4"
What appears to be happening is that the notify.slack
service is getting invoked before the camera.record
service is complete, and the file out completely. I inserted a delay of 15 seconds to match the record duration; clearly that isn’t long enough.
I could lengthen that delay interval before invoking the notify service, but that just seems like a hack. I’d really like some sort of a wait/pause action until the camera.record
service finishes its work and I know that the file is ready to be used.
I believe that the camera.record
service invocation is running asynchronously with the rest of the automation’s action script, but I’m not aware of some synchronizing primitive that can be used here.