UI-Lovelace-Minimalist / UI

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

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

Closed andyblac closed 4 months ago

andyblac commented 5 months 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 5 months ago

+1

MemoryFreezer commented 5 months ago

Same issue after manual installation.

rmngrc commented 5 months ago

+1

llehouerou commented 5 months ago

+1

wilbiev commented 5 months 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 5 months ago

+1 with fresh installation (hacs) and ha 2024.6

andyblac commented 5 months 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 5 months 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 4 months 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 4 months 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 4 months 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 4 months ago

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

wilbiev commented 4 months 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 4 months 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 4 months 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 4 months 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 4 months 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 4 months 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 4 months 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!!!

lyneld commented 4 months ago

@wilbiev - similar to karelkryda, below is what I got:

  1. No, I did not select the Gihub option while installing.
  2. Yes, restarted multiple times.
  3. Version I'm running is Core 2024.6.4, Supervisor 2024.06.2, Operating System12.4, Frontend 20240610.1.
  4. My JSON looks pretty much like karelkryda:
      {
        "data": {
          "community_cards_enabled": false
        },
        "disabled_by": null,
        "domain": "ui_lovelace_minimalist",
        "entry_id": "01ea84bf542d55e3e240c324442a3f52",
        "minor_version": 1,
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "title": "",
        "unique_id": null,
        "version": 1
      }

Will try your config changes and report back!

karelkryda commented 4 months ago

@wilbiev I've applied changes to the config. The changes were reflected in the UI, but after trying to use the configuration UI after the change, it caused the container to freeze again.

lyneld commented 4 months ago

Can report the same - I updated the config file. Restarted HA. Then went into integration, Minimalist UI and tried to configure but got the same "hang & crash" result. Interestingly though, my home-assistant.log.1 file has thousands (over 8000) lines of:

2024-07-02 00:09:11.202 ERROR (MainThread) [custom_components.ui_lovelace_minimalist.base] HACS Frontend repo "weather-radar-card" is not installed, See Integration Configuration.

Am I missing something? I installed all the required cards, including Simple Weather Card. Will try installing Weather Radar Card and see if that helps.

karelkryda commented 4 months ago

@lyneld The installation of 3 additional libraries is due to the adaptive template - see. Minimalist UI documentation. I personally installed these components, but it did not affect the result.

warmfire540 commented 4 months ago

@lyneld 2024-07-02 00:09:11.202 ERROR (MainThread) [custom_components.ui_lovelace_minimalist.base] HACS Frontend repo "weather-radar-card" is not installed, See Integration Configuration.

these are 2 separate cards, you can see from the name of the card in the error

image

lyneld commented 4 months ago

Adding the weather-radar-card didn't seem to help. Its still stuck and crashing. I've also added the other resources recommended in the adaptive wiki (state-switch, layout-card). No luck though.

wilbiev commented 4 months ago

Issue can be closed. Solve by update v1.3.10.