I would love to be able to create something like a “Calendar card” in Lovelace to list events from the camera with a clickable link to the videos. And an option to save the videos locally.
Possibly also the option to use the “download video” in automations to auto-download all videos from events of a certain type (e.g. “event_data - type: animal”)
According to the official docs, the procedure to access the video is:
Step 1: Retrieve the camera URL
Use Gethomedata method for the user. In the array “cameras”, retrieve the vpn_url for the camera you’re interested in
Step 2: Retrieve the video_id
Use Gethomedata, Getnextevents, Getlasteventof or Geteventsuntil to retrieve the video_id of the events array.
Step 3: Call the m3u8 index with the camera_url and the video id
If your app and the camera are on the same local network, add /camera_url/vod/(your_video_id)/index_local.m3u8 to access the video. If not, add /camera_url/vod/(your_video_id)/index.m3u8 to access the video
Step 1 is already ok I guess.
Step 2 should be easy enough to trigger when a callback from an event is coming in.
So then we need a way to “store” the link between the event and the url. And this is where I thought the calendar interface could be used as it already have the neccesary fields (maybe use “location” as the URL, or set it as “description” for the event), and you don’t need to implement a lot of logic around displaying og ordering of events.
I think it should be possible to automate downloading of new videos by getting the url from the calendar-event as long as the calendar entry is created before the rest of the event handler is triggered.