Skip to content

Conversation

@knightzac19
Copy link

@knightzac19 knightzac19 commented Feb 5, 2025

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.

@knightzac19
Copy link
Author

Just to clarify I wasn't looking for approvals, this still needs a lot more work to be finished

@knightzac19 knightzac19 marked this pull request as draft February 5, 2025 16:00
@blockarchitech
Copy link

@knightzac19 are you still working on this? I'd love to get this working if possible. How can I help out?

@knightzac19
Copy link
Author

@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.

@blockarchitech
Copy link

Awesome! Love to hear it! Let me know if I could be of any help.

@knightzac19 knightzac19 changed the title add libraries for webrtc support Add KVS support for currently unsupported cameras Mar 3, 2025
@knightzac19 knightzac19 reopened this Mar 3, 2025
@knightzac19 knightzac19 marked this pull request as ready for review March 3, 2025 13:29
@knightzac19
Copy link
Author

@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.

Copy link

@blockarchitech blockarchitech left a 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) | - |

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 🙂

Copy link
Author

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(

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.

Copy link
Author

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)

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 🙂

Suggested change
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)

Copy link
Author

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

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?

Copy link
Author

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

from urllib.parse import parse_qs, urlparse

import urllib

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.

Copy link
Author

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

}


KVS_CAMS = {"AN_RSCW", "AN_RDB1"}

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,
     ...
    }
]

Copy link
Author

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"]

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.

panic(err)
}

// _, err = peerConnection.AddTrack(videoTrack)

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

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.

Copy link
Author

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

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.

Copy link
Author

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.

@ihatemyisp
Copy link

Can confirm, this works excellently.

@knightzac19
Copy link
Author

@mrlt8 Would you be able to take a look?

@JoaquinBeceiro
Copy link

There are any plans to merge this? @mrlt8

@knightzac19
Copy link
Author

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...

@JoaquinBeceiro
Copy link

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

@MinnesotaMean
Copy link

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...

Any way I could test this build?

@knightzac19
Copy link
Author

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...

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.

@MinnesotaMean
Copy link

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...

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.

@knightzac19
Copy link
Author

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...

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.

@MinnesotaMean
Copy link

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...

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.

@JoaquinBeceiro
Copy link

Maybe is time to fork this repo since the author @mrlt8 hasn't given any signs of life. Any volunteer? @knightzac19 ?

@JoaquinBeceiro
Copy link

No updates?

@knightzac19
Copy link
Author

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.

@JoaquinBeceiro
Copy link

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

@knightzac19
Copy link
Author

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.

@knightzac19
Copy link
Author

@JoaquinBeceiro Here's the dev docker image if you would like to see how it works with your cameras, ghcr.io/knightzac19/docker-wyze-bridge:dev

Just know that it's going to be very chatty in the logs.

@blockarchitech
Copy link

blockarchitech commented Apr 9, 2025

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.

@outpoints
Copy link

@JoaquinBeceiro Here's the dev docker image if you would like to see how it works with your cameras, ghcr.io/knightzac19/docker-wyze-bridge:dev

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
[-10] IOTC_ER_UNLICENSE

@IDisposable
Copy link

I could merge this PR into my fork (since it's fully setup for actual Add-In deploy)... is this ready @knightzac19 ?

@outpoints
Copy link

Have you been able to test his fork and see if it's working? @IDisposable
I'd really appreciate if this was incorporated into your fork if it is!

@IDisposable
Copy link

IDisposable commented May 18, 2025 via email

@JoaquinBeceiro
Copy link

@IDisposable is kvs support available on your fork? Thank you for all your work!

@IDisposable
Copy link

@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.

@JoaquinBeceiro
Copy link

JoaquinBeceiro commented May 29, 2025

@JoaquinBeceiro Here's the dev docker image if you would like to see how it works with your cameras, ghcr.io/knightzac19/docker-wyze-bridge:dev

Just know that it's going to be very chatty in the logs.

Tried with this image and not working for me (product_model | GW_BE1)

[front-door] [-10] IOTC_ER_UNLICENSE

image

@Enrique1414
Copy link

@JoaquinBeceiro Here's the dev docker image if you would like to see how it works with your cameras, ghcr.io/knightzac19/docker-wyze-bridge:dev
Just know that it's going to be very chatty in the logs.

Tried with this image and not working for me (product_model | GW_BE1)

[front-door] [-10] IOTC_ER_UNLICENSE

image

Same here, getting IOTC_ER_UNLICENSE for product LD_CFP

wyze-bridge | [WyzeBridge] 🎉 Connecting to WyzeCam Floodlight Pro - Garage Cam on
wyze-bridge | [garage-cam] [-10] IOTC_ER_UNLICENSE

@IDisposable
Copy link

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.

@aderbique
Copy link

@IDisposable Do you need any help with that latest task? Would be nice to finally get this PR merged and support added

@IDisposable
Copy link

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!)

@outpoints
Copy link

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wyze Battery Cam Pro not supported

9 participants