herikw / home-assistant-custom-components

Atag One Custom components for Home-Assistant
GNU General Public License v3.0
11 stars 5 forks source link

Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble #40

Closed hotzenwalder closed 10 months ago

hotzenwalder commented 10 months ago

Added the Atag One integration through HACS. When trying to add it to the dashboard, the configuration wizard fails to run. It says 'Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble'. Home Assistant is running on a Synology DS224+ in Docker. Other integrations works flawlessly, even the standard ATAG integration. I think it's trying to discover my ATAG One, which fails.

The error reads

2024-01-03 20:44:59.685 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/auth.py", line 233, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/headers.py", line 31, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/view.py", line 149, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/decorators.py", line 63, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/config/config_entries.py", line 147, in post return await super().post(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/data_entry_flow.py", line 71, in post result = await self._flow_mgr.async_init( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/config_entries.py", line 880, in async_init flow, result = await task ^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/config_entries.py", line 908, in _async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lsiopy/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 389, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/atagone/config_flow.py", line 49, in async_step_user ip_address = await AtagOneApi().async_discover() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/atagone/wrapper/atagoneapi.py", line 84, in async_discover return addr ^^^^ UnboundLocalError: cannot access local variable 'addr' where it is not associated with a value

herikw commented 10 months ago

Hi hotzenwalder,

Just released a new version that will fix the issue you have. (when it doesn't find a Atag One device on your local network) Please have a try with this release (v3.0.7). Please note that you need to enter the IP address manually after the discovery timeout. (30 secs)

Btw. not sure why your Atag One can not be discovered, but probably because you are on a vnet in Docker? Discovery broadcasts to other lan segments (vnets) are not send by default. Are you also having issues with the discovery of other devices? One thing to deal with this is to set the correct network adapter in the /config/network section? This should be the adapter that's in your local network.

hotzenwalder commented 10 months ago

It's working now. After a time-out I can manually add the IP address of the ATAG host. Hope this one will be more stable and not loose the connection every once and awhile.

My HA installation is installed in a Docker container on a seperate Docker network behind a reverse proxy (Traefik). Some devices can still be automatically detected (Philips Hue, Chromecast etc), but other devices need manual setup, like ATAG.

herikw commented 10 months ago

The Atag Discovery is using an UDP broadcast message which do not pass the proxy server. But indeed manually configuring an IP address should do as well.