Generic Camera - Record when Motion detected by Sensor?

I’m semi-new to trying to create automation. One I’d like to do is record footage from my Generic Camera (It connects via HTTP using RTSP.

I would like my Aqara motion sensor to trigger an event to make the camera footage record for a period of time, or while the motion is detected by the sensor, and then stop, and save the footage somewhere. I’d love to upload it to a OneDrive location, but that’s maybe asking a lot.

I see there is a Stream service, but struggling to work it out. Is there a way to start streaming to a file, and then stopping, and then upload? Or copying/saving it to a location on my Home Assistant hardware? I am running on a large SSD drive, so space isn’t an issue (now).

For interest sake, the camera is a Wyze Cam V2, but as it’s using the Generic Camera type in HA, I’m not sure the make makes any difference.

I have this at the moment as an automation:

alias: Record Front Door
description: ""
  - type: motion
    platform: device
    device_id: 4d727454e9a999ba25cedd7557b00d40
    entity_id: 373c998453c894cfa937394718cde899
    domain: binary_sensor
condition: []
  - service: camera.record
      entity_id: camera.front
      duration: 30
      lookback: 0
      filename: /tmp/{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4
mode: single

But I see no file appear in the /tmp folder.

Looking at a Trace for the automation, it seems it did try. But - no file.

Ah wait… I see an error:

Can't write /tmp/20230825-114133.mp4, no access to path!

I’m not a linux pro… Where should I be saving the file? Or should I be granting permissions?

OK, I found that I need to add this to my configuration.yaml:

    - /tmp

Now HA says it worked…


But no file.


(Not sure why it says “Total 4” - when I see only 1)

OK, I think the issue is that for some reason, HA cannot record from my Generic cameras. It seems to be picking up an old camera that I used on Synology Servalance Station… But none of my Generic Cameras (The ones I actually use, and can see on my dashboard) show up.

Still can’t get a file to arrive. Any help would be great

Did you get this to work?

I’m about to try and setup a Nedis Wi-Fi camera and try to integrate it into HA through the generic camera platform. If that’s even possible, I would love to have the videos or snapshots that the camera takes when something trips the in-built motion sensor saved in some way. Preferably not on the SSD I run HA from.

Of course it’s possible with the cloud service of the camera, but I don’t really care for corporative cloud services.

So would be really interesting to hear if you or anyone else reading this, got this to work.

it is working for me. using a generic camera and record service.
Will record a tutorial on how to set this up.

Would very much like to see your tutorial :+1:

editing started. recording done. It will be uploaded as soon as possible.


Would be a very interesting tutorial! I’m in too!

Hi, is it possible save recording file na NAS? Or only in local HA folders? Thanks