Setup
Home Assistant VM
Home Assistant 2022.7.5
Supervisor 2022.07.0
Operating System 8.2
Frontend 20220707.1 - latest
Folder called scripts
configuration.yaml line contains
script: !include_dir_merge_named scripts
script name: camera_recording.yaml
Based on the solution by @@bt04 given titled How does my automation know when a camera.record service on a stream is complete? I created the following script
camera_recording:
description: Record from camera. Wait until finished. Save file name in latest_<source>
mode: parallel
max: 8 # 1 thread per camera. 8 cameras
variables:
- source: kitchen
timestamp: "{{ as_timestamp(now()) }}"
file_name: "{{ source }}-{{ timestamp | timestamp_custom('%d%m%Y-%H%M%S') }}.mp4"
duration: 10
- source: hall
timestamp: "{{ as_timestamp(now()) }}"
file_name: "{{ source }}-{{ timestamp | timestamp_custom('%d%m%Y-%H%M%S') }}.mp4"
duration: 10
...
sequence:
- service: camera.record
data_template:
entity_id: "camera.{{ source }}"
filename: "/config/www/cameras/{{ file_name }}"
duration: "{{ duration }}"
lookback: 5
- wait_for_trigger:
- platform: event
event_type: folder_watcher
event_data:
event_type: closed
file: "{{ file_name }}"
timeout:
seconds: "{{ duration + 10 }}"
continue_on_timeout: false
- service: input_text.set_value
data_template:
entity_id: "input_text.latest_{{ source }}"
value: "{{ file_name }}"
- service: notify.telegram
data:
title: "Camera detected motion. What is it?"
message: "Motion Detected!"
data:
video:
- file: "/config/www/cameras/{{ file_name }}"
caption: Camera Motion
On reloading the script the script (script.camera.record) shows up as unavailable.
Other scripts in the folder work
The automation attempts to look for script.camera.record but obviously cannot find it.
I’ve checked formatting and it appears to be in order.
Is what I’m attempting to do even possible or is there a more elegant way to do what I want to achieve.
Best regards.