Hello everyone!
I am new to Home Assistant and am trying to create an automation that records a 15-second clip and sends it to Telegram when the door is opened. I have connected a USB camera directly to my PC and added it to Home Assistant using motionEye. I am using 2 automations for this:
alias: Trigger Video Recording
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.contact_sensor_door
from: "off"
to: "on"
condition: []
action:
- service: camera.record
data:
entity_id: camera.camera1
duration: 15
lookback: 5
filename: /tmp/entrance_{{ as_timestamp(now()) | int }}.mp4
mode: single
&
alias: Send Recorded Entrance Video
description: ""
trigger:
- platform: event
event_type: folder_watcher
event_data:
event_type: closed
condition:
- condition: template
value_template: "{{ trigger.event.data.file.startswith('entrance_') }}"
action:
- service: notify.me
data_template:
message: ""
data:
video:
file: "{{ trigger.event.data.path }}"
caption: "{{now().strftime('%Y-%m-%d %H:%M:%S')}}"
mode: single
Problem: The video in Telegram does not play and instead shows a white square. However, if the video is downloaded to a phone, it works. Various methods have been tried, but the problem is not understood. The only remaining thought is that the problem may be with the codec, but it is unclear how to add video re-encoding to another codec in the second automation in Home Assistant.
Has anyone encountered this problem when sending videos in Telegram? How was it solved?