mihai-dinculescu / tapo

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
MIT License
318 stars 30 forks source link

Support for security cameras #185

Open ClementNerma opened 3 months ago

ClementNerma commented 3 months ago

For personal uses, I'd love to have access to an API to control my surveillance devices (e.g. change the camera's angle, toggle it on/off, etc.)

Tapo cameras (C-series) support the ONVIF protocol which is a widespread standard for controlling IP cameras.

I'm not sure if adding RTSP streaming capabilities to this crate would be relevant, it may be more relevant to make another create for that.

I'm trying to search on how to connect to the cameras (which seems to be different than for smart plugs or bulbs as it uses separate credentials). It may represent a pretty big work so not sure if I can do this myself but I'll try to dig into this and see what I can find.

mihai-dinculescu commented 3 months ago

I've got a C220 myself, and I'll support your initiative. Yes, basic controls would be swell at first, but I'm willing to consider RTSP as well afterwards.

https://github.com/mihai-dinculescu/tapo/issues/144 should contain useful information.

ClementNerma commented 3 months ago

The main problem is that almost no code from this crate could be re-used for the C-series. As they all use ONVIF (for control) and RTSP (for streaming) instead of basic plain old HTTP requests, everything needs to be written from the ground up.

Maybe it would be interesting to make another crate (e.g. tapo-camera) for that? And reference it in the main crate? I don't know.

What's sure is that we're not going to write a full client for ONVIF and/or RTSP, better let the job be done by specialized libraries. For the ONVIF part, there's unfortunately not that much software solutions in Rust.

There's still the onvif crate but it's unfortunately not very maintained and doesn't seem to work with current Tapo cameras. I tried the discovery example and it failed to find anything.

Maybe inspiration could be taken from the unofficial Tapo Camera addon for Home Assistant, which while being pretty unstable to me managed to control the camera and live stream from it.

mihai-dinculescu commented 3 months ago

Let's worry about RTSP when we get there 😄

Looking at https://github.com/JurajNyiri/pytapo, the authentication should be fairly easy to integrate into the current abstractions, and the API is the same as that of the other devices already implemented.

The only annoying aspect is that the same authentication doesn't work for H200. I was hoping to shoot two birds with one stone 😞 .