-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Hi! I'm using the Solarman custom integration and encountering a warning regarding a blocking file operation inside the event loop.
Log Warning:
Detected blocking call to open with args ('/config/custom_components/solarman/inverter_definitions/custom_parameters.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:
Full Traceback:
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 154, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever
self._run_once()
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, 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 2634, in _async_forward_entry_setup
await entry.async_setup(self.hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup
await self.__async_setup_with_context(hass, integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 99, in async_setup_entry
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 230, in async_setup_entry
return await self._platforms[key].async_setup_entry(config_entry)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 349, in async_setup_entry
return await self._async_setup_platform(async_create_setup_awaitable)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 379, 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:
System Info:
- Home Assistant version: 2025.7.2
- Solarman integration version: 1.0.0
- Hardware/Environment: [optional]
Suggested Fix:
Consider replacing the blocking open() call with asynchronous file reading (e.g. using aiofiles) to comply with Home Assistant's async guidelines: https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
Thank you for maintaining this integration!