-
-
Notifications
You must be signed in to change notification settings - Fork 817
Description
Hi @al-one,
First of all, thank you for this excellent integration! It works great for controlling my devices. I'm reaching out regarding an issue with downloading videos from my Xiaomi Smart Doorbell 3S.
Environment
Device Model: madv.cateye.mi3sg (Xiaomi Smart Doorbell 3S)
Integration: Xiaomi Miot (latest via HACS)
HA Setup: Home Assistant OS
Entity: camera.madv_mi3sg_7bd8_video_doorbell
Problem Description
I have successfully created a shell script triggered by Home Assistant automations to download event videos (motion/ring) using the parameters from the camera entity (access_token, stream_address, etc.).
However, I've encountered a specific problem:
In the Mi Home app, the full event video is available (e.g., ~9 seconds long).
When downloading the same event using ffmpeg (or yt-dlp) with the stream_address URL provided by the integration, I only get the first 3-4 seconds of the video.
Technical Details from Logs
From the ffmpeg logs, I can see that the HLS playlist reports the correct duration (Duration: 00:00:08.89), but the download stops early with an error:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fd2c6990500] stream 0, offset 0xbb2: partial file
[in#0/hls @ 0x7fd2c6c12b00] Error during demuxing: Invalid data found when processing input
It seems that the HLS stream served to ffmpeg contains a corrupted or incomplete final segment, whereas the Mi Home app (and likely Xiaomi's own cloud infrastructure) has a mechanism to retrieve the full file.
Current Workflow
Automation trigger (motion detected).
Shell command calls script with parameters: --token, --url (the stream_address), --time, --type.
Script attempts to download using ffmpeg and falls back to yt-dlp, but both yield the same short video.
Question / Feature Request
Is there a better way to download the complete event video file directly via the integration's cloud API?
I see that the integration provides services like xiaomi_miot.get_properties and xiaomi_miot.call_action. Is it possible to retrieve a direct URL to the fully assembled .mp4 file from the Xiaomi cloud for a specific event (identified by motion_video_time)? Or is there a specific call_action to trigger a video download?
I believe this would provide a more reliable method than parsing a potentially corrupted HLS stream with external tools. Any guidance on the correct MIoT services or properties to use for this would be greatly appreciated.
What I've Tried
Using ffmpeg with various options (-reconnect, different headers).
Using yt-dlp with --allow-unplayable-formats and extensive retry options.
Analyzing the stream_address URL – it appears to be an HLS master playlist with encrypted segments.
Thank you for your time and for creating this amazing integration!