bremor / bureau_of_meteorology

Custom component for retrieving weather information from the Bureau of Meteorology.
MIT License
190 stars 31 forks source link

'unknown error' at configuration when submitting lat and long #16

Closed snowgumrd closed 4 years ago

snowgumrd commented 4 years ago

Hi, I'm having trouble setting up the integration.

At the Configuration -> Integration page, after I click on Bureau of Meteorology and it asks me to confirm my lat and long co-ordinates, I click submit and get an 'unknown error'. Log below.

Logger: custom_components.bureau_of_meteorology.config_flow Source: custom_components/bureau_of_meteorology/PyBoM/collector.py:32 Integration: Bureau of Meteorology (documentation, issues) First occurred: 10:41:54 PM (4 occurrences) Last logged: 10:43:19 PM

Unexpected exception Traceback (most recent call last): File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "/opt/Home-Assistant/lib/python3.8/asyncio/base_events.py", line 1021, in create_connection raise exceptions[0] File "/opt/Home-Assistant/lib/python3.8/asyncio/base_events.py", line 1006, in create_connection sock = await self._connect_sock( File "/opt/Home-Assistant/lib/python3.8/asyncio/base_events.py", line 920, in _connect_sock await self.sock_connect(sock, address) File "/opt/Home-Assistant/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connect return await fut File "/opt/Home-Assistant/lib/python3.8/asyncio/selector_events.py", line 499, in _sock_connect sock.connect(address) OSError: [Errno 99] Cannot assign requested address

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/bureau_of_meteorology/config_flow.py", line 35, in async_step_user await collector.get_location_name() File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 32, in get_location_name response = await session.get(url) File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request conn = await self._connector.connect( File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect proto = await self._create_connection(req, traces, timeout) File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _createconnection , proto = await self._create_direct_connection( File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection raise last_exc File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/opt/Home-Assistant/lib/python3.8/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.weather.bom.gov.au:443 ssl:default [Cannot assign requested address]

bremor commented 4 years ago

Thanks for reporting a problem. Would you mind sharing your lat/Lon? You can round to two decimal places if you would like to hide your exact location

snowgumrd commented 4 years ago

Sure. Lat: -37.78 Lon: 145.17

bremor commented 4 years ago

I'm not sure what happened here, I don't get an error using those coordinates. I do have some suggestions:

snowgumrd commented 4 years ago

I'm not sure what happened here, I don't get an error using those coordinates. I do have some suggestions:

  • Was your internet down at the time?
  • Can you try uninstall/reinstall the entire integration?
  • Can you try different coordinates?
  • Is there anything unique about your environment that is worth mentioning?

Nope. Internet is fine. Tried removing and reinstall, it didn't work either. I tried melbourne CBD co-ordinates. No luck. My home assistant instance is run on a QNAP NAS. Might that be the cause? I've got lots of integrations running but every one is unique I guess.

bremor commented 4 years ago

Mate, i'm totally stumped. It looks like your system is failing to bind to a local port maybe? Might be a restriction on your QNAP? Might be worth some googline that specific error, Cannot connect to host api.weather.bom.gov.au:443 ssl:default [Cannot assign requested address]

snowgumrd commented 4 years ago

Mate, i'm totally stumped. It looks like your system is failing to bind to a local port maybe? Might be a restriction on your QNAP? Might be worth some googline that specific error, Cannot connect to host api.weather.bom.gov.au:443 ssl:default [Cannot assign requested address]

Actually, now that you mention it, i had a similar issue with the solcast integration. I had to change SSL as no to get it working.

How would I go about doing that with this integration?

bremor commented 4 years ago

Do you mean you had to change it to http or you had to turn off ssl cert validation?

snowgumrd commented 4 years ago

Do you mean you had to change it to http or you had to turn off ssl cert validation? In the py, I had to override ssl = false

bremor commented 4 years ago

Within collector.py, try updating the following line and then reboot, there are three occurances. If this works I will include it in the next release.

            response = await session.get(url)

to

            response = await session.get(url, ssl=False)
snowgumrd commented 4 years ago

Within collector.py, try updating the following line and then reboot, there are three occurances. If this works I will include it in the next release.

            response = await session.get(url)

to

            response = await session.get(url, ssl=False)

That did it! Clearly there's a pattern here. Should I be concerned about not using SSL?

bremor commented 4 years ago

Your environment maintains a list of trusted certificate authorities, which would normally be kept up to date automatically. The ssl cert that BoM are using is signed by "DigiCert Global Root CA". So if you can, you should install this Root CA into your trusted certificate store in your environment. I’m thinking it’s best if I don’t put ssl=False into the next release.

Subject | DigiCert Secure Site ECC CA-1 Valid from 15/Feb/2019 to 15/Feb/2029 Issuer | DigiCert Global Root CA

bremor commented 4 years ago

I have release version 0.7, but I have also created a new branch for you where SSL is disabled. I will maintain this branch, the only difference will be that ssl=False bit. It will only ever appear in "beta versions" image

DavidFW1960 commented 4 years ago

did you add back day 6 yet?

bremor commented 4 years ago

Haven't done it, but will do it. Have created an issue so i don't forget. https://github.com/bremor/bureau_of_meteorology/issues/18

snowgumrd commented 4 years ago

I have release version 0.7, but I have also created a new branch for you where SSL is disabled. I will maintain this branch, the only difference will be that ssl=False bit. It will only ever appear in "beta versions" image

Cheers mate! Thanks for your help.