Hi,
I had the same problem and asked Chat GPT ;-).
The solutions works for me, the latest snapshot is shown on my dashboard per “virtual camera” and Timelapse works too.
I changed the file path a bit and also the trigger for the Timelapse (1h after sunset).
Greetings,
Creating a Timelapse Video with Home Assistant and Wittcom HP10 Camera
This guide will help you set up a timelapse video creation using your Wittcom HP10 camera with Home Assistant. The camera captures snapshots via a URL, which supports the “GET” method. We will cover:
- Fetching a snapshot every 5 minutes and saving it temporarily.
- Displaying the latest snapshot on the Home Assistant dashboard.
- Creating a daily timelapse from the snapshots and deleting them afterward.
1.) Fetching Snapshots Every 5 Minutes
First, create a shell script to fetch and save the snapshot.
Shell Script (fetch_snapshot.sh
):
#!/bin/bash
timestamp=$(date +"%Y%m%d%H%M%S")
url="http://<camera-ip>/capture"
output_dir="/config/www/snapshots"
/usr/bin/curl -o "$outputdir/snapshot$timestamp.jpg" $url
cp "$outputdir/snapshot$timestamp.jpg" "$outputdir/snapshotlatest.jpg"
Make sure to replace <camera-ip>
with your camera’s IP address. Save this script in /config/scripts/fetch_snapshot.sh
.
Make the script executable (optional)
chmod +x /config/scripts/fetch_snapshot.sh
Home Assistant Configuration
Add the following to configuration.yaml
to define the shell command:
shell_command:
fetchsnapshot: /bin/bash /config/scripts/fetchsnapshot.sh
Create an automation in automations.yaml
to run the script every 5 minutes:
- alias: Fetch Snapshot Every 5 Minutes
trigger:
platform: time_pattern
minutes: "/5"
action:
service: shellcommand.fetchsnapshot
2.) Displaying the Latest Snapshot on the Dashboard
Add a local file camera to configuration.yaml
to display the latest snapshot:
camera:
- platform: local_file
name: Latest Snapshot
filepath: /config/www/snapshots/snapshotlatest.jpg
3.) Creating a Daily Timelapse
Shell Script (create_timelapse.sh
):
Create the script to generate the timelapse video and delete the old snapshots / old Timelapse videos:
#!/bin/bash
output_dir="/config/www/snapshots"
timelapse_dir="/config/www/timelapses"
today=$(date +"%Y%m%d")
# Create the timelapse video
ffmpeg -framerate 10 -pattern_type glob -i "$output_dir/snapshot_*.jpg" -c:v libx264 "$timelapse_dir/timelapse_$today.mp4"
# Remove all snapshots except snapshot_latest.jpg
find $output_dir -type f -name 'snapshot_*.jpg' ! -name 'snapshot_latest.jpg' -delete
# Keep only the last 180 timelapse videos
cd $timelapse_dir
ls -t | sed -e '1,180d' | xargs -d '\n' rm --
Save this script in /config/scripts/create_timelapse.sh
and make it executable:
chmod +x /config/scripts/create_timelapse.sh
Home Assistant Configuration
Add the shell command to configuration.yaml
:
shell_command:
createtimelapse: /bin/bash /config/scripts/createtimelapse.sh
Create an automation in automations.yaml
to run the script daily:
- alias: Create Timelapse Daily
trigger:
platform: time
at: "23:59:00"
action:
service: shellcommand.createtimelapse