jaydeethree / Home-Assistant-weatherdotcom

Home Assistant custom component/integration for Weather.com
GNU General Public License v3.0
35 stars 5 forks source link

'Unknown Error' during integration setup #1

Closed Valdorama closed 1 year ago

Valdorama commented 1 year ago

I'm trying to install this integration but am getting an error when trying to submit the settings (i.e. API key, location etc.).

This is what is displayed:

image

I am following the instructions to grab the API key from the wunderground.com page.

The log contains the following:

This error originated from a custom integration.

Logger: custom_components.weatherdotcom.config_flow
Source: custom_components/weatherdotcom/config_flow.py:68
Integration: Weather.com (documentation, issues)
First occurred: 08:42:15 (4 occurrences)
Last logged: 08:54:15

Weather.com config responded with HTTP error 400: Bad Request

I have also tried truncating the location coordinates (to just 2 decimal places) but still get the same error.

Running Home Assistant Container 2023.5.4

Valdorama commented 1 year ago

Just came back and tried this again and sure enough it seems to be working now.

jaydeethree commented 1 year ago

Sorry for not responding sooner - it looks like I didn't have notifications set up correctly, so GitHub didn't tell me that you had opened an issue. Anyway, I'm glad to hear it's working now! I'm not sure why you were getting an HTTP 400 earlier, but it sounds like some sort of temporary issue that fixed itself.

sviperz commented 10 months ago

Hey, I'm having the same issue while adding the integration, but the log is different. Could you please look into it?

Logger: custom_components.weatherdotcom.config_flow
Source: custom_components/weatherdotcom/config_flow.py:73
Integration: weatherdotcom (documentation, issues)
First occurred: 1:08:55 PM (6 occurrences)
Last logged: 1:11:26 PM

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/weatherdotcom/config_flow.py", line 73, in async_step_user
    raise Exception
Exception

UPDATE Before the error from above I also noticed this error:

Logger: custom_components.weatherdotcom.config_flow
Source: custom_components/weatherdotcom/config_flow.py:68
Integration: Weather.com (documentation, issues)

Weather.com config responded with HTTP error 403: Forbidden

Seems like this is due to wunderground.com is not available in my country, so I got apiKey via VPN.

jaydeethree commented 10 months ago

Seems like this is due to wunderground.com is not available in my country, so I got apiKey via VPN.

Interesting, I didn't know that Wunderground had that restriction. This might explain some of the issues that have been reported about API keys not working - maybe they serve different API keys to different countries and some of those keys don't work with Weather.com. I'll add a note about this to the README. Thanks for reporting this issue!

sviperz commented 10 months ago

Yep, but not Wunderground, it's Weather.com. I'm from Belarus. Russia is probably affected too.

image

jaydeethree commented 10 months ago

I've added some additional info about this in the README. Thanks again for reporting this!

sviperz commented 10 months ago

Sure, you're welcome!

There is one more thing that is strange. I added routes to send weather.com and wunderground.com traffic through VPN located in the area without restrictions. And curl shows no 403 errors now (which it does without VPN) when I check from within HA, but still I'm getting the same Weather.com config responded with HTTP error 403: Forbidden message in the log and can't add the integration.

[core-ssh ~]$ curl -v weather.com
*   Trying 104.102.42.111:80...
* Connected to weather.com (104.102.42.111) port 80 (#0)
> GET / HTTP/1.1
> Host: weather.com
> User-Agent: curl/8.0.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Server: AkamaiGHost
< Content-Length: 0
< Location: https://weather.com/
< Expires: Sun, 03 Sep 2023 21:08:03 GMT
< Cache-Control: max-age=0, no-cache, no-store
< Pragma: no-cache
< Date: Sun, 03 Sep 2023 21:08:03 GMT
< Connection: keep-alive
< Set-Cookie: speedpin=4G; expires=Sun, 03-Sep-2023 21:38:03 GMT; path=/; domain=.weather.com; secure
< Set-Cookie: ci=TWC-Locale-Group=US&X-Origin-Hint=Goto-Prod&TWC-GeoIP-Country=NL&TWC-Privacy=gdpr; path=/; domain=.weather.com; secure
< Server-Timing: cdn-cache; desc=HIT
< Server-Timing: edge; dur=1
< Access-Control-Max-Age: 86400
< Access-Control-Allow-Credentials: false
< Access-Control-Allow-Headers: *
< Access-Control-Allow-Methods: GET,POST,OPTIONS
< Access-Control-Allow-Origin: *
< Property-id: TWC-WX-Prod
< TWC-PATH-LOCALE: /
< TWC-Subs: none
< TWC-Unit: u
< TWC-Privacy: gdpr
< TWC-GeoIP-Region: 
< TWC-GeoIP-City: AMSTERDAM
< TWC-GeoIP-DMA: 
< TWC-GeoIP-LatLong: 52.35,4.92
< TWC-GeoIP-Country: NL
< TWC-Device-Class: desktop
< TWC-Locale-Group: US
< TWC-Connection-Speed: 4G
< TWC-Variation: eyJzZGsiOnsidmFsdWUiOiJiIn19
< Strict-Transport-Security: max-age=15552000; preload
< TWC-AK-Req-ID: 18ab11c2
< X-Origin-Hint: Goto-Prod
< Server-Timing: ak_p; desc="1693775283899_34664585_413864386_9_6796_6_0_-";dur=1
< 
* Connection #0 to host weather.com left intact

[core-ssh ~]$ curl -v wunderground.com
*   Trying 92.122.104.178:80...
* Connected to wunderground.com (92.122.104.178) port 80 (#0)
> GET / HTTP/1.1
> Host: wunderground.com
> User-Agent: curl/8.0.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Server: AkamaiGHost
< Content-Length: 0
< Location: https://wunderground.com/
< Expires: Sun, 03 Sep 2023 21:08:51 GMT
< Cache-Control: max-age=0, no-cache
< Pragma: no-cache
< Date: Sun, 03 Sep 2023 21:08:51 GMT
< Connection: keep-alive
< Set-Cookie: speedpin=4G; expires=Sun, 03-Sep-2023 21:38:51 GMT; path=/; domain=.wunderground.com; secure
< Set-Cookie: ci=TWC-Locale-Group=US&X-Origin-Hint=WU-Next-Default&TWC-GeoIP-Country=NL&TWC-Privacy=gdpr; path=/; domain=.wunderground.com; secure
< Property-id: TWC-WU-Prod
< X-Robots-Tag: noindex, nofollow
< TWC-Privacy: gdpr
< TWC-GeoIP-Region: 
< TWC-GeoIP-City: AMSTERDAM
< TWC-GeoIP-DMA: 
< TWC-GeoIP-LatLong: 52.35,4.92
< TWC-GeoIP-Country: NL
< TWC-Device-Class: desktop
< TWC-Locale-Group: US
< TWC-Connection-Speed: 4G
< X-Origin-Hint: WU-Next-Default
< 
* Connection #0 to host wunderground.com left intact
jaydeethree commented 10 months ago

All of the endpoints used by this integration are on api.weather.com - can you try connecting to that and see if it works for you? You may need to add a special route for that domain also.

sviperz commented 10 months ago

Cool, it works now! I could have checked it in the code 🙃️ Thanks!

jaydeethree commented 10 months ago

Awesome, I'm glad that worked!

sviperz commented 10 months ago

Finally, this is a weather integration that has everything I need. Thanks again!