jabesq-org / pyatmo

Simple API to access Netatmo weather station data from any python script (for Netatmo information, see www.netatmo.com)
MIT License
26 stars 28 forks source link

169.254 IP Address issue workaround #354

Closed codyc1515 closed 10 months ago

codyc1515 commented 1 year ago

Hi. I did a little probing today to see if it may be possible to add a workaround for the 169.254 IP Address issue referenced in #347. I lodged an issue with them earlier today about this too as I strongly believe this is a Netatmo device firmware to cloud API integration bug. However, I have experienced first hand the delays from Netatmo in the past.

I understand that the process today is now roughly:

  1. Call the /homestatus cloud API endpoint
  2. Call the vpn_url for the device (/command/ping cloud API endpoint)
  3. Notice the local_url begins with http://169.254 (problematic)
  4. Mark the specific device as unavailable (as opposed to failing the entire integration)

My suggestion is instead of 4, let's:

  1. Lookup mDNS for any entries under local._netatmo-lcomm._tcp.
  2. Each device under the Netatmo service will have an attribute for mac_address against the mDNS entry. The MAC value is similarly present in the homestatus call we made in step 1.

We can now match the mDNS mac_address attribute to the /homestatus MAC address and substitute in the IP address from mDNS over the top of the http://169.254.x.x address. This will preserve the security key in the path of the URL and allow us to continue to connect to the device locally.

Screenshot 2022-11-01 at 17 12 01 Screenshot 2022-11-01 at 17 12 11 Screenshot 2022-11-01 at 17 11 59

cgtobi commented 1 year ago

That is an interesting approach. Are you interested in implementing this yourself?

codyc1515 commented 1 year ago

I could but wanted to feel out the idea first to make sure that you and the team would be okay with it. This issue doesn't happen particularly often but when it does it's especially frustrating.

cgtobi commented 1 year ago

The current solution is not as sophisticated. I'd welcome this implementation.

codyc1515 commented 1 year ago

Astounding. I still have not heard back from Netatmo in some 4 months.

I'm having an issue with one of my two cameras not showing in Home Assistant (no issues in the Security app or the Netatmo website) and, on checking, it's this issue again.

codyc1515 commented 1 year ago

There appears to be some checks for the presence of an 169.254.x.x IP address which should exclude the local_url from being retunred; however, my instance appears to not be falling back to the VPN. Need to do some sleuthing.

codyc1515 commented 10 months ago

Never heard back from Netatmo until I tried to return my cameras to the retailer then silent again. Proceeded with the refund and no issues since :)