Put a Tapo camera in privacy mode when the router sees my phone
I have a Tapo C225 indoor camera that should record only when nobody is home. Tapo's own home/away switching was unreliable, so I built frogcam. It puts the camera into privacy mode when my router shows that my phone is present.
frogcam is one Docker container on the LAN. Every 30 seconds it asks the TP-Link router for its client list. If my phone's MAC is there, I am home and privacy mode goes on. If the phone has been gone for 5 minutes, privacy mode goes off. The router's client list has been highly reliable compared to Tapo home/away and other forms of detection. No cloud, no phone location, no Home Assistant.
The rest of this post is the specification. It is written so that an agent can rebuild the project from it.
Specification
Build a long-running service, packaged as one Docker container and configured only by environment variables. It watches a TP-Link router for my phone and sets privacy mode on a Tapo camera. Structure, naming, error handling and tests are your call.
Hardware
- Router: TP-Link Archer AX10 v3, read with
tplinkrouterc6u. - Camera: Tapo C225, controlled over its local API with
pytapo.
Behavior
- Poll the router's client list on an interval, 30 seconds by default.
- Home means any configured phone MAC is an active client. Home sets privacy mode on, away sets it off.
- Going away requires the phone to be continuously missing for a grace period, 5 minutes by default. Phones drop off wifi briefly and the camera should not flap. Coming home takes effect immediately.
- The first observation after startup is applied with no grace.
- Write to the camera only on a home/away transition, and retry until it succeeds. Toggling privacy by hand in the Tapo app should stick until the next transition.
- If the router poll fails, keep the last known state.
- Find the camera's IP by its MAC in the same client list on every poll, so a new DHCP lease does not break anything. Allow a static IP as a fallback.
Things you would not guess
- The router allows one admin web session. Log in, fetch, and log out on every poll. This still kicks a human out of the router web UI.
- The camera only accepts username
adminwith the Tapo cloud (app login) password. The cloud email as username does not work. A "Camera Account" from the app's Advanced Settings does not work either. - The camera counts every login handshake. After 10 failures it locks out for 30 minutes and answers
Temporary Suspension: Try again in 1800 seconds. - Design camera access around that lockout. Pass
retryStok=Falseto pytapo so it does not retry logins silently. Never retry a failed fresh login. Honor the timer in the lockout message. Wait 30 minutes after a credential rejection. Back off exponentially on anything else. - If the cloud accepts the password and the camera does not, the cloud password was changed recently. Power-cycle the camera so it re-syncs.
- The phone must have its randomized wifi address turned off for the home network.
Commands
frogcam run # the poll loop, default
frogcam devices # list router clients, to find the MACs
frogcam camera # show camera info and privacy state
frogcam privacy on|off # set privacy mode once
frogcam cloud-check EMAIL # verify the Tapo password without touching the camera
cloud-check exists because testing credentials against the camera spends lockout attempts. It makes one call to the TP-Link cloud instead, and error_code 0 in the response means the password is right:
requests.post("https://wap.tplinkcloud.com/", json={
"method": "login",
"params": {
"appType": "Tapo_Android",
"cloudUserName": email,
"cloudPassword": password,
"terminalUUID": str(uuid.uuid4()),
},
})