
I have a Ubiquiti Protect camera system in my home, with some cameras indoors and some outdoors. For privacy reasons I only want the indoor cameras to be on and recording when the house is empty. I’ve created a Python script that runs on the Ubiquiti Dream Machine device that manages the cameras and turns these cameras on and off accordingly.
I use Smarthings at home for smart home control of things like lights and doors. I’ve configured it to recognize each family member’s cell phone and to use them to detect when people are at home or away. I’ve configured Smarthings with a set of automation routines that change the status of our home location to “Away” when all family members are gone, and back to “Home” when one or more of them return. My Python script uses this location status information from Smarthings to decide when to turn on the power to the indoor cameras and when to turn it off.
Ubiquiti cameras use Power-Over-Ethernet (POE) power. Turning them on and off involves telling the network switch to turn off POE power on the switch port the camera is plugged into. The script is written assuming that the network switch involved is controllable through Ubiquiti’s Network Console application. I use Ubiquiti network switches for my cameras. I have no idea if this would work with any other switch brands.
I’ve made this script available on github.