lawtancool / hass-control4

Control4 integration for Home Assistant
Apache License 2.0
26 stars 9 forks source link

Unable to open "Configuration Panel": 500 internal Server Error #30

Open deltamikeromeo opened 1 week ago

deltamikeromeo commented 1 week ago

When attempting to open the configuration panel, I get the following error: "Error Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble"

Logs attached below. I don't have any alarms in control4 so I'm unsure why it is failing at that key.

2024-09-16 16:32:58.968 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry control4_hc800_000FFF580817 for control4 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/control4/init.py", line 123, in async_setup_entry await entry_data[CONF_DIRECTOR].getUiConfiguration() File "/usr/local/lib/python3.12/site-packages/pyControl4/director.py", line 303, in getUiConfiguration return await self.sendGetRequest("/api/v1/agents/ui_configuration") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyControl4/director.py", line 64, in sendGetRequest await checkResponseForError(await resp.text()) File "/usr/local/lib/python3.12/site-packages/pyControl4/error_handling.py", line 98, in checkResponseForError dictionary = xmltodict.parse(response_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/xmltodict.py", line 378, in parse parser.Parse(xml_input, True) xml.parsers.expat.ExpatError: mismatched tag: line 6, column 2 2024-09-16 16:33:00.995 WARNING (event_thread_0) [sucks] Ping did not reach VacBot. Will retry. 2024-09-16 16:33:22.315 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 262, in post return await super().post(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 70, in wrapper return await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 77, in post return await self._post_impl(request, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl result = await self._flow_mgr.async_init( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 343, in async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/control4/config_flow.py", line 203, in async_step_init _LOGGER.debug(self.entry_data[CONF_ALARM_ARM_STATES])


KeyError: 'alarm_arm_states'
deltamikeromeo commented 1 week ago

I think this is related to the recent 1.3 release. Please see below:

2024-09-20 16:18:39.559 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_default_certs with args (<ssl.SSLContext object at 0x7f8ac4cd50>, <Purpose.SERVER_AUTH: _ASN1Object(nid=129, shortname='serverAuth', longname='TLS Web Server Authentication', oid='1.3.6.1.5.5.7.3.1')>) inside the event loop by custom integration 'control4' at custom_components/control4/init.py, line 257: await entry_data[CONF_WEBSOCKET].sio_connect(director.director_bearer_token) (offender: /usr/local/lib/python3.12/ssl.py, line 713: context.load_default_certs(purpose)), please create a bug report at https://github.com/lawtancool/hass-control4/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_default_certs Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 752, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/control4/init.py", line 81, in async_setup_entry await refresh_tokens(hass, entry) File "/config/custom_components/control4/init.py", line 257, in refresh_tokens await entry_data[CONF_WEBSOCKET].sio_connect(director.director_bearer_token) 2024-09-20 16:18:41.008 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry control4_hc800_000FFF580817 for control4 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/control4/init.py", line 123, in async_setup_entry await entry_data[CONF_DIRECTOR].getUiConfiguration() File "/usr/local/lib/python3.12/site-packages/pyControl4/director.py", line 303, in getUiConfiguration return await self.sendGetRequest("/api/v1/agents/ui_configuration") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyControl4/director.py", line 64, in sendGetRequest await checkResponseForError(await resp.text()) File "/usr/local/lib/python3.12/site-packages/pyControl4/error_handling.py", line 98, in checkResponseForError dictionary = xmltodict.parse(response_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/xmltodict.py", line 378, in parse parser.Parse(xml_input, True) xml.parsers.expat.ExpatError: mismatched tag: line 6, column 2

deltamikeromeo commented 1 week ago

Hi @lawtancool, please see above. I think there is an issue with the new bearer auth in the 1.3 release. It worked immediately after restoring 1.2.1

From: https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_default_certs SSLContext.load_default_certs does blocking disk I/O to load the certificates from disk.

The following helpers ensure that the blocking I/O will happen in the executor: