Skip to content

blocking file operation was detected inside the event loop, which can negatively affect performance or cause instability. #769

@AditaNi

Description

@AditaNi

Hi Stephan,

I have done an analysis with Copilot, because of this errors:

"Detected blocking call to open with args ('/config/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml',) inside the event loop by custom integration 'solarman' at custom_components/solarman/solarman.py, line 31: with open(self.path + self.lookup_file) as f: (offender: /config/custom_components/solarman/solarman.py, line 31: with open(self.path + self.lookup_file) as f:), please create a bug report at https://github.com/StephanJoubert/home_assistant_solarman/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open 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 229, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 215, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 271, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 712, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 683, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2050, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2654, in _async_forward_entry_setup await entry.async_setup(self.hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 672, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 761, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 100, in async_setup_entry return await hass.data[DATA_COMPONENT].async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 221, in async_setup_entry return await self._platforms[key].async_setup_entry(config_entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 418, in async_setup_entry return await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 448, in async_setup_platform awaitable = create_eager_task(awaitable, loop=hass.loop) File "/usr/src/homeassistant/homeassistant/util/async.py", line 44, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/config/custom_components/solarman/sensor.py", line 89, in async_setup_entry _do_setup_platform(hass, entry.options, async_add_entities) File "/config/custom_components/solarman/sensor.py", line 54, in _do_setup_platform inverter = Inverter(path, inverter_sn, inverter_host, inverter_port, inverter_mb_slaveid, lookup_file) File "/config/custom_components/solarman/solarman.py", line 31, in init with open(self.path + self.lookup_file) as f:"

🔍 What’s Happening
The custom integration solarman is trying to open a YAML file using Python’s open() function:

python
with open(self.path + self.lookup_file) as f:
This line is not asynchronous, meaning it pauses the entire event loop while reading the file. Home Assistant expects all I/O operations in custom components to be non-blocking (i.e., use async methods) to keep the system responsive.

⚠️ Why It Matters
Blocking calls inside the event loop can freeze or slow down your Home Assistant instance.

It’s especially problematic during startup or when many integrations are initializing.

🛠️ What You Can Do
Report the issue: The integration author asks you to file a bug report here: GitHub: StephanJoubert/home_assistant_solarman/issues

Temporary workaround: If the integration still works and this is just a warning, you can continue using it—but keep an eye out for performance issues.

Developer fix (if you're comfortable): The offending line should be rewritten using asynchronous file access, like:

python
async with aiofiles.open(self.path + self.lookup_file, mode='r') as f:
content = await f.read()
But this requires modifying the integration code and ensuring aiofiles is available.

I hope it helps.....if not...then...not good.

Regards
Adrian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions