dannerph / homeassistant-solcast

Apache License 2.0
19 stars 3 forks source link

Cannot connect to host api.solcast.com.au:44 #1

Closed snowgumrd closed 3 years ago

snowgumrd commented 3 years ago

Hi @dannerph , I'm trying to install your awesome component and I've followed the instructions but I get an error from Home Assistant. What am I doing wrong?

"Cannot connect to host api.solcast.com.au:443 ssl:default [Cannot assign requested address]"

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

dannerph commented 3 years ago

Hi @snowgumrd,

it might be related to the SSL issue another user had in the Home Assistant forum (https://community.home-assistant.io/t/rest-api-command-platform-fails-on-post-to-external-url-solcast/143238/44)

On what plattform your Home Assistant installation is running on?

snowgumrd commented 3 years ago

Hi @snowgumrd,

it might be related to the SSL issue another user had in the Home Assistant forum (https://community.home-assistant.io/t/rest-api-command-platform-fails-on-post-to-external-url-solcast/143238/44)

On what plattform your Home Assistant installation is running on?

I'm running it on my Qnap server. Basically this: https://www.qnapclub.eu/en/qpkg/299

Maybe I should try setting the SSL setting to false too?

dannerph commented 3 years ago

Yes, if you like it would be good to try with SSL disabled, even if I would advise to use SSL enabled in anycase. Let me know if you need some help. Could you report back if it was working? Then I can integrate the SSL setting as configuration.

snowgumrd commented 3 years ago

te the S

Ok. I thought I knew what to do to disable SSL but I didn't :D Can you advise what should line 112 in init.py look like? @dannerph

dannerph commented 3 years ago

The Code should look like

        async with aiohttp.ClientSession() as session:
            async with session.get(
                url=f"{self._base_url}{path}", params=params, ssl=False
            ) as resp:
                json = await resp.json()
                status = resp.status

This should only be a test, as unencrypted communication is not be the solution. My guess: the required root CA is not part of the QNAP OS. I am running Home Assistant within Docker on a Synology NAS and I have no problems like this.

snowgumrd commented 3 years ago

The Code should look like

        async with aiohttp.ClientSession() as session:
            async with session.get(
                url=f"{self._base_url}{path}", params=params, ssl=False
            ) as resp:
                json = await resp.json()
                status = resp.status

This should only be a test, as unencrypted communication is not be the solution. My guess: the required root CA is not part of the QNAP OS. I am running Home Assistant within Docker on a Synology NAS and I have no problems like this.

It worked! I was hoping for the time series data forecast so I know what the forecast peak and period is, but at least the integration is connecting to the API to begin with.

dannerph commented 3 years ago

Time series forecast is something on my todo list. I am currently thinking of having one sensor per day with (quarter) hourly attributes.

In order to fix this issue, I will add the disable SSL option as configuration and some meaningful error reporting.

dannerph commented 3 years ago

I now implemented some additional config options in a new branch, not yet tested.

I will close this issue.

snowgumrd commented 3 years ago

I now implemented some additional config options in a new branch, not yet tested.

I will close this issue.

Awesome. Thank you for your help and your efforts!