core icon indicating copy to clipboard operation
core copied to clipboard

Aemet not working after 2024.5.2

Open djrm05 opened this issue 9 months ago • 14 comments

The problem

Following error is logged. `Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection raise exceptions[0] File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('212.128.97.177', 443)

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

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aemet_opendata/interface.py", line 119, in api_call resp: ClientResponse = await self.aiohttp_session.request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection _, proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection raise last_exc File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host opendata.aemet.es:443 ssl:default [Connect call failed ('212.128.97.177', 443)]`

I have tested the API key through "https://opendata.aemet.es/opendata/api/observacion/convencional/todas?api_key= MYAPIKEY" and got a 200 status as success, so not sure what is happening

What version of Home Assistant Core has the issue?

2024.5.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Aemet

Link to integration documentation on our website

https://www.home-assistant.io/integrations/aemet/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

djrm05 avatar May 07 '24 20:05 djrm05

Hey there @noltari, mind taking a look at this issue as it has been labeled with an integration (aemet) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of aemet can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign aemet Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


aemet documentation aemet source (message by IssueLinks)

home-assistant[bot] avatar May 07 '24 20:05 home-assistant[bot]

Same problem here with the same log error

Luis1988 avatar May 07 '24 22:05 Luis1988

Another there with same problem and log.. Cannot connect to host opendata.aemet.es:443 ssl:default Key API is working with 200 ok tested from browser

alfredros avatar May 08 '24 06:05 alfredros

Same here

Albruaje avatar May 08 '24 06:05 Albruaje

Testing from the browser, it works but it takes 1 minute to reply.

@alfredros Can you check your response time? please, open the inspect window and disable cache in the network tab (chrome).

image

mcrodriguezb avatar May 08 '24 06:05 mcrodriguezb

Response from AEMET:

"Le informamos que ha habido una incidencia técnica que las personas de la unidad responsable están intentando solventar a la mayor brevedad que permiten sus recursos humanos y materiales. Lamentamos las molestias, agradecemos su aviso y su interés en nuestro servicio público."

"We inform you that there has been a technical incident that the people in the responsible unit are trying to resolve as soon as their human and material resources allow. We regret the inconvenience, we appreciate your notice and your interest in our public service."

Albruaje avatar May 08 '24 06:05 Albruaje

Yes, the API is unstable right now and not fully recovered. Let's wait for the AEMET staff to fix it, as I already reported here https://github.com/home-assistant/core/issues/116973#issuecomment-2097695618

Noltari avatar May 08 '24 06:05 Noltari

Testing from the browser, it works but it takes 1 minute to reply.

@alfredros Can you check your response time? please, open the inspect window and disable cache in the network tab (chrome).

image

At the first try took a few seconds to display the response, around 45sec.

Query: https://opendata.aemet.es/opendata/api/observacion/convencional/todas?api_key=MYKEY

Let me paste a screenshot of the test: image

it seems that the query takes about 1 minute to response... maybe the integration marked as timeout before it. It's clear that AEMET has a problem to reply all queries quickly...

alfredros avatar May 08 '24 10:05 alfredros

I've got this:

`Registrador: homeassistant.components.aemet.coordinator Fuente: helpers/update_coordinator.py:347 integración: AEMET OpenData Ocurrió por primera vez: 3 de mayo de 2024, 8:16:32 p. m. (19 ocurrencias) Último inicio de sesión: 6 de mayo de 2024, 9:44:30 p. m.

Error fetching aemet data: Error fetching aemet data: [Errno 104] Connection reset by peer`

mabusdogma avatar May 08 '24 10:05 mabusdogma

AEMET API is clearly unstable right now.

If you curl to opendata.aemet.es you will see you may connect, then drop, and next 3/4 attempts will fail with connection reset.

We'll need to wait for them to address this on the backend side.

raulcnadal avatar May 08 '24 13:05 raulcnadal

The aemet open data web is down, I suppose that will be the source of the integration problems. Would it be possible to add a cache so that the latest downloaded data remains visible? Lately this integration fails a lot and the dashboard with the empty integration looks very ugly. Furthermore, meteorological data does not usually change much, so it is better to have some old data than nothing.

ajavibp avatar May 08 '24 19:05 ajavibp

Aemet is down but it's always a nightmare this integration because of Aemet api

lluisd avatar May 09 '24 08:05 lluisd

The aemet open data web is down, I suppose that will be the source of the integration problems. Would it be possible to add a cache so that the latest downloaded data remains visible? Lately this integration fails a lot and the dashboard with the empty integration looks very ugly. Furthermore, meteorological data does not usually change much, so it is better to have some old data than nothing.

It would be possible to add some kind of caching to improve the user experience due to the unstability of the AEMET API. However, I don't have time for doing this, so feel free to create a PR with that functionality on the integration library repo: https://github.com/Noltari/AEMET-OpenData

Noltari avatar May 09 '24 08:05 Noltari

The aemet open data web is down, I suppose that will be the source of the integration problems. Would it be possible to add a cache so that the latest downloaded data remains visible? Lately this integration fails a lot and the dashboard with the empty integration looks very ugly. Furthermore, meteorological data does not usually change much, so it is better to have some old data than nothing.

It would be possible to add some kind of caching to improve the user experience due to the unstability of the AEMET API. However, I don't have time for doing this, so feel free to create a PR with that functionality on the integration library repo: https://github.com/Noltari/AEMET-OpenData

I wish I was capable, but I don't have the necessary knowledge. I was just trying to provide a useful idea. Thank you so much

ajavibp avatar May 09 '24 18:05 ajavibp

Well, if cosmetics is just what you want, you can always go to Developer Tools and set the last state manually to those sensors.

I've got Accuweather also configured so when AEMET fails, I can quickly switch to it until it's addressed, which at least provides real data, but the method I mentioned above is valid to at least get something on your dashboard.

raulcnadal avatar May 10 '24 00:05 raulcnadal

Today is working for me, let's see for how long...

alfredros avatar May 11 '24 09:05 alfredros

Also working for me, and I have prepared in Home Assistant a selector to choose between AEMET and AccuWeather, adapting all the automations and panels, so I can be covered if the AEMET API fails again.

Albruaje avatar May 11 '24 21:05 Albruaje

It appears to be working but I have other error...

Luis1988 avatar May 11 '24 21:05 Luis1988

As proved, the AEMET OpenData API was unstable and there was nothing that we could do on our side, so I'm closing this.

Noltari avatar May 12 '24 08:05 Noltari

@home-assistant close

Noltari avatar May 12 '24 08:05 Noltari