core icon indicating copy to clipboard operation
core copied to clipboard

ZAMG Integration says "500 Internal Server Error Server got itself in trouble" while trying to add an new station

Open oe3arc opened this issue 2 years ago • 3 comments

The problem

After the two ZAMG sensors had timeouts during fetching data every now and then, I tried to add third station in order to verify whether it's related to specific weather stations or if it's a common problem.

Trying to add another station ended with the Error message "Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble".

After a restart the two stations showed data not available, an error in the log was shown: 2022-11-06 07:42:50.096 ERROR (MainThread) [homeassistant.components.zamg] Unexpected error fetching zamg data: ‘NoneType’ object has no attribute ‘get’.

Then I deleted the two stations and tryed to re-add a ZAMG integration via the GUI. This still ends up showing the error-message box "Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble"

The log says:

Logger: aiohttp.server Source: components/zamg/config_flow.py:36 First occurred: 16:58:59 (5 occurrences) Last logged: 17:08:19

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 148, in post return await super().post(request) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post result = await self._flow_mgr.async_init( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 225, in async_init flow, result = await task File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in _async_init result = await self._async_handle_step(flow, flow.init_step, data, init_done) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/zamg/config_flow.py", line 36, in async_step_user closest_station_id = await self._client.closest_station( File "/usr/local/lib/python3.10/site-packages/zamg/zamg.py", line 103, in closest_station self._station_id = min(stations, key=_comparable_dist) TypeError: 'NoneType' object is not iterable

What version of Home Assistant Core has the issue?

2022.11.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZAMG

Link to integration documentation on our website

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

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

oe3arc avatar Nov 06 '22 16:11 oe3arc

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

Code owner commands

Code owners of zamg can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zamg Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


zamg documentation zamg source (message by IssueLinks)

home-assistant[bot] avatar Nov 06 '22 16:11 home-assistant[bot]

Same Problem here,

imported Zamg from config had undefined entites because the correlation did not happen correct, removing & trying to set it up initially worked afterwards (although with errors) and failed after a few minutes.

now when trying to set it up I get the same 500 which did not happen before

gotschi avatar Nov 06 '22 16:11 gotschi

Hi, The problem with getting 500 internal server error is caused from a expired server certificate of https://dataset.api.hub.zamg.ac.at/ which the integration is using to read the data.

The certificate has expired today in the morning.

killer0071234 avatar Nov 06 '22 17:11 killer0071234

ZAMG seems to have renewed the certificates. I was able to add stations again right now.

oe3arc avatar Nov 07 '22 08:11 oe3arc

monitored it a few hours - works now. issue closed.

oe3arc avatar Nov 07 '22 20:11 oe3arc

Unfortunately the error described here also occurred with me yesterday.

ccie11827 avatar Dec 05 '22 08:12 ccie11827

See the parallel discussion in https://github.com/home-assistant/core/issues/81745. The ZAMG datahub looked bricked - right now I was able again to fetch data with the small test described in the above mentioned discussion.

oe3arc avatar Dec 05 '22 11:12 oe3arc