UI-Lovelace-Minimalist / UI

UI-Lovelace-Minimalist is a "theme" for HomeAssistant
https://ui-lovelace-minimalist.github.io/UI/
Other
1.57k stars 420 forks source link

Error: Detected blocking call to open inside the event loop #1501

Open andyblac opened 3 weeks ago

andyblac commented 3 weeks ago

error is log at startup.

Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 15:33:57 (350 occurrences)
Last logged: 15:34:06

Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 486: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 262: with open(dst, 'wb') as fdst:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 486, in configure_ulm shutil.copytree(
Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 492: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 260: with open(src, 'rb') as fsrc:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 492, in configure_ulm shutil.copytree(
Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 492: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 262: with open(dst, 'wb') as fdst:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 492, in configure_ulm shutil.copytree(
Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 498: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 260: with open(src, 'rb') as fsrc:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 498, in configure_ulm shutil.copytree(
Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 498: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 262: with open(dst, 'wb') as fdst:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 498, in configure_ulm shutil.copytree(
voxmatt commented 3 weeks ago

+1

MemoryFreezer commented 3 weeks ago

Same issue after manual installation.

rmngrc commented 3 weeks ago

+1

llehouerou commented 2 weeks ago

+1

wilbiev commented 2 weeks ago

I fixed two issues with my limited knowledge of Python and Home Assistant. You can find the modified files init.py and base.py in my GitHub repository https://github.com/wilbiev/UI/tree/main/custom_components/ui_lovelace_minimalist The solved issues are the hanging (problem in the reload of the integration) and the log messages 'Detected blocking call'

lgraf commented 2 weeks ago

+1 with fresh installation (hacs) and ha 2024.6

andyblac commented 2 weeks ago

I fixed two issues with my limited knowledge of Python and Home Assistant. You can find the modified files init.py and base.py in my GitHub repository https://github.com/wilbiev/UI/tree/main/custom_components/ui_lovelace_minimalist The solved issues are the hanging (problem in the reload of the integration) and the log messages 'Detected blocking call'

maybe make a Pull Request, might help speed up fix to this git?

thanks BTW, added your file manually no more errors 👍

istornz commented 1 week ago

Same issue on my side, I dumped the error code:

2024-06-22 18:53:02.999 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'ui_lovelace_minimalist' at custom_components/ui_lovelace_minimalist/base.py, line 480: shutil.copytree( (offender: /usr/local/lib/python3.12/shutil.py, line 262: with open(dst, 'wb') as fdst:), please create a bug report at https://github.com/UI-Lovelace-Minimalist/UI/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 447, in _async_setup_component await asyncio.gather( File "/usr/src/homeassistant/homeassistant/setup.py", line 449, in <genexpr> create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) 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/ui_lovelace_minimalist/__init__.py", line 124, in async_setup_entry return await async_initialize_integration(hass=hass, config_entry=config_entry) File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 104, in async_initialize_integration startup_result = await async_startup() File "/config/custom_components/ui_lovelace_minimalist/__init__.py", line 93, in async_startup not await ulm.configure_ulm() File "/config/custom_components/ui_lovelace_minimalist/base.py", line 480, in configure_ulm shutil.copytree(

warmfire540 commented 1 week ago

I fixed two issues with my limited knowledge of Python and Home Assistant. You can find the modified files init.py and base.py in my GitHub repository https://github.com/wilbiev/UI/tree/main/custom_components/ui_lovelace_minimalist The solved issues are the hanging (problem in the reload of the integration) and the log messages 'Detected blocking call'

maybe make a Pull Request, might help speed up fix to this git?

thanks BTW, added your file manually no more errors 👍

can you add these to the main repo?

HuffYk commented 6 days ago

I fixed two issues with my limited knowledge of Python and Home Assistant. You can find the modified files init.py and base.py in my GitHub repository https://github.com/wilbiev/UI/tree/main/custom_components/ui_lovelace_minimalist The solved issues are the hanging (problem in the reload of the integration) and the log messages 'Detected blocking call'

@wilbiev could you please create a PR just for those 2 files? It works for me also. I tried different fix: changing shutil for aioshutil (https://github.com/HuffYk/UI/releases/tag/v1.3.9-aioshutil ), but looks like it sometimes works, sometimes not. Your fix works so far (here I merged just those 2 files: https://github.com/HuffYk/UI/releases/tag/v1.3.9-wilbiev )

wilbiev commented 3 days ago

I try to find time to solve 3 remaining issues before creating a PR:

  1. First time users still experience hanging issues after configuring the integration - cause: Minimalist does not save the initial configuration items correctly in the core.config_entries file. Workaround: adding the entries manually. When the entries exist they can be modified.
  2. After configuring the integration 3 routines are run twice. This doesn't give side effects but is not very neat.
  3. There are guidelines for submitting PR-requests. I was not able to setup a decent dev environment for the pre-commit testing. The provide template contains deprecated components and my knowledge is too limited.
FG2300 commented 2 days ago

does this fix the hanging problem and if so how do i download this

wilbiev commented 2 days ago

I created a PR with the new code which should solved the hanging issue and the log messages 'Detected blocking call'. The code check fails while deprecated options are used for isort. Locally all tests were successfully passed. Let's wait for the review.

wilbiev commented 2 days ago

The code from the init.py and base.py files at https://github.com/wilbiev/UI/tree/main/custom_components/ui_lovelace_minimalist can be manually copy/paste to your local deployment. This should not be too difficult if you are able to write dashboards in code with UI Minimalist.

lyneld commented 3 hours ago

Thanks a lot for sharing the fix @wilbiev but I still seem to have the hanging problem. I see you mentioned some issues with first time users (I'm a first timer here) - what steps should I follow? Here's what I did - installed UI Minimalist through HACS, installed all the pre-requisite cards, restarted HA, edited both init.py and base.py files (in custom_components/ui_lovelace_minimalist) with ones from your repo, and then proceeded with the integration configuration. This didn't seem to work and still hangs.

karelkryda commented 3 hours ago

@lyneld I can confirm what you are saying. I'm currently trying to set up the UI with fixed files, but the integration configuration window causes my container and the entire HA to overload and crash.

So far, however, it seems that the UI is loading even without performing actions in the configuration window. So I'll try to do it this way for now.

wilbiev commented 1 hour ago

@lyneld I have a few questions:

  1. Did you select the GitHub-option when installing the UI Minimalist integration?
  2. Did you restart HA after the installation steps and before configuring the integration?
  3. Which version of HA are you using?
  4. Are these options available in the config/.storage/core.config_entries file under domain "ui_lovelace_minimalist"?: "options": { "language": "English (GB)", "sidepanel_enabled": true, "sidepanel_title": "UI Lovelace Minimalist", "sidepanel_icon": "mdi:flower", "adaptive_ui_enabled": true, "adaptive_ui_title": "UI Lovelace Minimalist", "adaptive_ui_icon": "mdi:flower", "theme": "minimalist-desktop", "theme_path": "themes/", "include_other_cards": false, "community_cards_enabled": true, "community_cards": [] },
karelkryda commented 1 hour ago

@wilbiev, let me answer your questions.

  1. no, I didn't authorize Minimalist UI with Github
  2. yes, tried multiple times
  3. Core - 2024.6.4; Frontend - 20240610.1 in Docker via stable tag
  4. no, my JSON looks like this:
    {
    "data": {
    "community_cards_enabled": false
    },
    "disabled_by": null,
    "domain": "ui_lovelace_minimalist",
    "entry_id": "8e0aa53862406d703587f0a49cc59907",
    "minor_version": 1,
    "options": {},
    "pref_disable_new_entities": false,
    "pref_disable_polling": false,
    "source": "user",
    "title": "",
    "unique_id": null,
    "version": 1
    },
wilbiev commented 37 minutes ago

@karelkryda replace '"options": {},' in config/.storage/core.config_entries under domain "ui_lovelace_minimalist" with:

"options": { "language": "English (GB)", "sidepanel_enabled": true, "sidepanel_title": "UI Lovelace Minimalist", "sidepanel_icon": "mdi:flower", "adaptive_ui_enabled": true, "adaptive_ui_title": "UI Lovelace Minimalist", "adaptive_ui_icon": "mdi:flower", "theme": "minimalist-desktop", "theme_path": "themes/", "include_other_cards": false, "community_cards_enabled": false, "community_cards": [] },

WARNING: editing the config/.storage/core.config_entries file is at own risk. A wrong config in this file can cause severe damage to your HA deployment!!!