-
-
Notifications
You must be signed in to change notification settings - Fork 243
Add KVS support for currently unsupported cameras #1420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Just to clarify I wasn't looking for approvals, this still needs a lot more work to be finished |
|
@knightzac19 are you still working on this? I'd love to get this working if possible. How can I help out? |
I switched gears and did get a POC working, just working on getting it to play nice with mediamtx. I will put up another PR when I have something fully working. |
|
Awesome! Love to hear it! Let me know if I could be of any help. |
|
@JoaquinBeceiro @blockarchitech @ihatemyisp Okay, I have this fully working now. I would of loved to use aiortc, but there was several bugs I hit that I wasn't seeing in other WebRTC implementations when connecting to the wyze cameras. So for now I'm using a golang proxy which uses pion. This is the same implementation that MediaMTX is using, so it was pretty easy to setup. It might need added to the other dockerfiles, I just wasn't 100% sure on that yet. |
blockarchitech
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works! I added a few comments but most of the code looks great. The only major thing is splitting up the Go app, and running it concurrently with the Python app.
Also: I don't have much (any) of a say in this, as I'm not a maintainer or anything, so feel free to totally ignore my comments 🙂
| | Wyze Battery Cam Pro | AN_RSCW | [⚠️](https://github.com/mrlt8/docker-wyze-bridge/issues/1011) | - | | ||
| | Wyze Cam Doorbell Pro 2 | AN_RDB1 | ✅ | - | | ||
| | Wyze Battery Cam Pro | AN_RSCW | ✅ | - | | ||
| | Wyze Cam Flood Light Pro [2K] | LD_CFP | [⚠️](https://github.com/mrlt8/docker-wyze-bridge/issues/822) | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, this should work now as it uses a similar API? I will give it a shot and see how it goes 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should in theory work for all cameras using KVS directly, I haven't gone threw their official list in the web app/android app to see what this fixes.
| app = Flask(__name__) | ||
| wb = WyzeBridge() | ||
| try: | ||
| subprocess.Popen( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of this. Can we start the Python app and the WHEP Proxy in the Dockerfile simultaneously? This could add extra latency to starting a camera stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't blocking the stream from starting, this starts up when flask starts.
| self.api.setup_mtx_proxy(cam_name=cam.name_uri, uri=stream.uri) | ||
|
|
||
| self.mtx.add_path(stream.uri, not options.reconnect) | ||
| self.mtx.add_path(stream.uri, not options.reconnect, cam.is_kvs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved into the above if cam.is_kvs statement? It's likely I'm misunderstanding something here, though 🙂
| self.mtx.add_path(stream.uri, not options.reconnect, cam.is_kvs) | |
| if cam.is_kvs: | |
| self.api.setup_mtx_proxy(cam_name=cam.name_uri, uri=stream.uri) | |
| self.mtx.add_path(stream.uri, not options.reconnect, cam.is_kvs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are doing a couple different things, the setup call is calling the wyze API to get the KVS setup started in the background for the proxy. The add_path call needs the is_kvs bool so it knows that it has to add a source path to MTX for the proxy instead of using the event bus.
| logger.info(f"[MTX] starting MediaMTX {getenv('MTX_TAG')}") | ||
| self.sub_process = Popen(["/app/mediamtx", "/app/mediamtx.yml"]) | ||
| self.sub_process = Popen( | ||
| ["./mediamtx", "./mediamtx.yml"], stdout=None, stderr=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to add stdout=None and stderr=None, considering the fact it wasn't there originally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, without that you don't see the output from MediaMTX in the docker output
app/wyzebridge/wyze_api.py
Outdated
| from urllib.parse import parse_qs, urlparse | ||
|
|
||
| import urllib | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random whitespace 🙂
I would go through and run black --fast if you haven't already. It should fix most of these kinds of issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using ruff which might be doing things differently
app/wyzecam/api_models.py
Outdated
| } | ||
|
|
||
|
|
||
| KVS_CAMS = {"AN_RSCW", "AN_RDB1"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do a list of dicts, like:
[
{
"model": "ABC_123",
"is_pro": False,
"is_kvs": False,
...
}
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just trying to follow the same pattern as before, not sure I want to refactor those in this PR?
| RUN chmod +x /usr/local/bin/whep_proxy | ||
| ENV PYTHONUNBUFFERED=1 FLASK_APP=frontend BUILD=$BUILD GITHUB_SHA=$GITHUB_SHA | ||
| WORKDIR /app | ||
| CMD ["flask", "run", "--host=0.0.0.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we run the Go proxy and the python app in parallel? This may alleviate some added latency when starting a stream with these new cams.
whep_proxy/main.go
Outdated
| panic(err) | ||
| } | ||
|
|
||
| // _, err = peerConnection.AddTrack(videoTrack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented code
| @@ -0,0 +1,532 @@ | |||
| package main | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is largely fine - there is a discussion to be had on whether it is worth introducing an entirely new app into the codebase - but I digress.
What I will ask though: is with my above comments of running this in parallel with the python app, there should probably be a config option to disable this server if we don't need it. Though, Go is extremely lightweight and the only thing we're doing here is opening another port. I am generally in favor of keeping this here. I don't think it would add that much added overhead that we really need to worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this just starts a tiny web app in a fraction of a second. The actual heavy lifting happens when you start adding streams to the bridge.
| @@ -0,0 +1,532 @@ | |||
| package main | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we split this file up? It's pretty large and that makes it a little hard to follow. For instance, we could move the types into it's own file, and maybe some helper functions for creating the necessary stuff to start streams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can look into it, I know Go can be a bit touchy with multiple files.
|
Can confirm, this works excellently. |
|
@mrlt8 Would you be able to take a look? |
…meras that do not need TUTK anymore
|
There are any plans to merge this? @mrlt8 |
|
There's probably still some work to be added now that a bunch more cameras no longer work with the original setup. I did find that Wyze sends a command to the camera to switch from 360p to 2.5k and such. That is not working in this setup yet, I'm working on figuring that part out now. My pion proxy is not connecting to the camera's datachannel at the moment and I'm not sure if it's docker or wyze not behaving... |
How can i test this on my HA installation? I dont know how can I help |
Any way I could test this build? |
I think at this point we're gonna have to look at officially forking this repo as we're not getting any responses from the owner any more. |
That's unforutnate, but I'd be happy to provide any testing needed. I have a Floodlight pro that I'm jumping through hoops to get into Frigate via a Tinycam pro server running in an android x86 vm on my main TrueNAS server. |
I have a Cam V3/V4 and Outdoor Battery Pro all working with KVS. I did find there's some additional flags Wyze uses to change resolution of the stream which I haven't fully worked out yet and kind of lost interest in finishing it as it doesn't look like it'll get merged upstream. If someone is willing to take the mantle and take over this project, I'll happily help get this PR going again, but I don't have the time or resources to fork it myself. |
@mrlt8 any comment? Would love to see this pushed up. |
|
Maybe is time to fork this repo since the author @mrlt8 hasn't given any signs of life. Any volunteer? @knightzac19 ? |
|
No updates? |
|
I have no plans on taking this project over, but I have restarted my work on this since I do have a real need for this to work. Once I get this fully working, I will update my fork and docker image with what I have come up with. I won't be providing any support for this though, but I will do my best to fix anything that comes that I have the capabilities to test. |
Sounds great! Let me know if you need some help |
|
I will say, I have KVS fully working, there is a switch Wyze does to switch resolutions which isn't working 100% of the time. Also the IOTC part of the code is conflicting with some of the work I have setup for the KVS cameras. I can probably push what I have up now and that will atleast get everyone's cameras working at their lowest resolution. Note however I am not sure any of the MQTT features will work or any other features that relied on FFMPEG processing the video and using TUTK IOTC commands. |
|
@JoaquinBeceiro Here's the dev docker image if you would like to see how it works with your cameras, Just know that it's going to be very chatty in the logs. |
|
Just want to chime in and say I do support @knightzac19 creating a fork we use as it looks like the original maintainer is long gone 🙂 clarification: not saying "take over the project". I don't think you should have to take the burden of support. |
Is this updated on your repo? You don't have an image for amd64 via the repo you posted and building it locally it still says |
|
I could merge this PR into my fork (since it's fully setup for actual Add-In deploy)... is this ready @knightzac19 ? |
|
Have you been able to test his fork and see if it's working? @IDisposable |
|
That's next on my list.
|
|
@IDisposable is kvs support available on your fork? Thank you for all your work! |
Not yet, but I'll be merging in a ton of changes (including KVS, hopefully) over the next couple of days. I'm still fighting with MediaMTX not storing recordings... so that's delaying other changes. |
Tried with this image and not working for me (
|
Same here, getting IOTC_ER_UNLICENSE for product LD_CFP wyze-bridge | [WyzeBridge] 🎉 Connecting to WyzeCam Floodlight Pro - Garage Cam on |
|
I suspect we're going to need to use a different license key for the referenced library. I have a GW_BE1 on my setup, so maybe I can watch the traffic and find it. |
|
@IDisposable Do you need any help with that latest task? Would be nice to finally get this PR merged and support added |
|
I've been doing a rewrite in Go... but given how all the cameras are now broken, I think I'll defer that for a bit and get KVS merged. Maybe even this Monday (holiday!) |
Any updates to your fork? :) |


Hello, I've added the basics for KVS ICE support for the Wyze Cameras that support it. I've used the wyze web interface to verify what API calls to make and double checked their APK for Android as well. As far as the video goes, that's kind of where my expertise stops as I don't have much experience setting up video streams with python.
If there's any suggestions on how to finish this implementation or where to look, I'll happily finish this PR 100%.
One thing I'm not 100% sure about with this is if you're able to use the KVS API if you don't have Cam Plus activated on that camera. I didn't see anything in the Wyze app that seemed to say so, I know the web live view blocks it though.
This should close #1011, #822, possibly add support for
AN_RDB1.