I’m trying to figure out a way I can specify 30 seconds before now so I can include a timestamp on a rtsp playback stream.
The end goal: when motion is detected at the front door, stream recorded video to living room tv (if on). I currently have this working with live video but by the time the automation triggers and casting loads, I’m usually watching people walk away rather than the recorded stream of them walking up to the door.
So for playback, I set up a generic camera feed with the following url
rtsp://admin:[email protected]:554/Streaming/tracks/501?starttime=20200823T150730z
I have used something similar to timestamp snapshots, so I think the following would work for “now” $(date +%Y%m%dT%H%M%S)z
I’m not entirely sure if I have to escape the ‘T’ (or break the date from the time) and I’m really not sure how to take 30 seconds off the timestamp. Has anyone done something similar before? Thanks for any help in advance.
So, while I’m fairly certain I have the url working correctly, I don’t think the camera url is dynamically loaded. So the timestamp is registered when home assistant is started, but isn’t updated when motion is detected. Unfortunately, I’ll have to go back to live view (unless anyone can chime in here stating otherwise).
I was wrong, the timestamp is not working. date +%Y%m%dT%H%M%Sz --date='30 seconds ago'
works with date (GNU coreutils) 8.28 but not with whatever version is packaged with BusyBox v1.31.1 which is what’s used in the home assistant docker image.
So I guess I’m back to my original question. I’ve tried a couple of things in the container but can’t figure out how to offset the time.
So I guess shell commands won’t work in urls, but looking at the generic ip camera component, templates do. This appears to be working, but I may need to fine tune the offset
I’m at least getting the correct timestamp in the thread exception now. There is no recent recording to test this out at the moment so I was expecting an error.
Edit: Adjusted the offset to the last recording and it does appear to be working!