shauntarves / wyze-sdk

A modern Python client for controlling Wyze devices.
The Unlicense
312 stars 49 forks source link

How to get remote WAN IP address of cameras #185

Open PrestonMcAfee opened 3 months ago

PrestonMcAfee commented 3 months ago

I have Wyze V3 cameras at a remote cabin connected to starlink. I am trying to use blue iris at my home to monitor them. Starlink changes the WAN IP frequently, often every five minutes (new satellite lock). I've been able to use wyze-sdk to get the local IP addresses of the cameras, but not the WAN IP address. (If I were running a computer there, I would just run dynamic DNS). Wyze monitors the WAN IP address because otherwise it could not communicate with the cameras. I have this working:

response = client.devices_list() for device in client.devices_list(): print(f"mac: {device.mac}") print(f"ip: {device.ip}")

which gets me the local IP, but not the starlink IP. I pulled all the attributes of the cameras and it does not contain the WAN IP. Is the WAN IP available from the Wyze SDK?

k0jdd commented 1 month ago

One thought would be to have something simple there at the remote cabin (maybe a raspberry-pi) use curl to discover the Public IP - a cron job could run every 5 min or so and take action if the IP has changed since the last query

curl icanhazip.com > public_ip.txt

if the IP has changed that same device would then place the output file (public_ip.txt) somewhere where you can find it -- which might be as simple as placing it in a drop box or a google drive

PrestonMcAfee commented 1 month ago

Thanks. That is definitely a fallback position, but if I'm doing that, I might as well run home assistant at the cabin and get its terrific functionality (I use HA at home so I am already familiar with it).

I figure the cameras must tell Wyze where they are located, though this could be by a hard-coded ping to a wyze-owned IP address.

k0jdd commented 1 month ago

I don' think the camera has any way to determine it's PUBLIC IP - nor does it need to.

I suspect what happens is the camera 'phones home' to the wyze server and identifies itself by mac_address, or something else immutable, and the server says "Oh, I know you and you are coming from PUBLIC IP x.x.x.x"

if the PUBLIC IP changes, the connection to the server is updated - somehow - obviously it works however they do it