I have gone thru this so let me tell you my story and where I am standing now.
Most cameras have a REST API or similar where you can get or set virtually any setting, you can simply use POST/GET HTTP requests to manage it, in some cases you’ll have to send specific parameters/XML.
You’ll find these manuals online depending on the maker. This works but your camera recording will be stuck with whatever options the camera supports whether it is cloud recording or to a microSD, if you’re lucky it will support your cloud storage options, FTP, etc.
In order to further customize your setup you can get something like MotionEye, it works. It will take care of the recording (even as far as uploading to your own Google Drive) and could also take of other stuff like motion detection, schedules, triggers, etc. It’s controllable via their API.
So I had a mix at first, I controlled my cameras PTZ directly with the CGI commands and all the recording and motion sensing on MotionEye with their API. I even had a trigger in MotionEye for certain cameras to do an HTTP request to my HA to send a notification to my phone that the motion sensing was triggered.
At the end of the day an update came and screwed my camera, it got updated to cloud only management with their own app or Google Assistant.
So now I have two cameras, DLINK brand and got rid of MotionEye (anyway it causes very high CPU and RAM usage).
Screw managing the recordings and having more components, I was unable to use the REST API on my camera after that update.
I had a cheap Xiaomi camera hacked and it was very unreliable, so I’m sticking to DLINK with their default software and recording options. Still worried about privacy issues but I either have the camera turned on and recording or completely turned off. You either want privacy or not, I’d never ever leave my camera recording while I’m home unless there’s contractors remodeling or working on something around my house.
So now these two cameras record to their own cloud providers as I have no other choice as microSD defeats the purpose as if someone breaks in they can just take the camera/MicroSD with them.
One of them is connected to a smart plug, the other one to a an Ubiquiti Unifi Switch PoE.
So I just control the power with the smart plug or the PoE switch based with a simple automation like the following one:
Either they’re on and recording or they’re not. I don’t see an scenario where I want to turn off motion detection but still have the camera turned on.
The only caveat of this is that the camera takes about 1-2 minutes to turn on and be available for streaming.
Works reliably, haven’t touched it in over a year. No issues with the camera not streaming, recording or whatever.
The bright side of my setup is that if you’re out of town and your HomeAssistant or PC where you have MotionEye, BlueIris or whatever decides to crash the camera recording/controls are independent from it. Also it can be independently managed with their app and I can still manage the power via the Unifi Controller for the PoE camera or the TP Casa app in the case of the camera connected to a smart plug (TPLink smart plug).