ha-solcast-solar: Detected blocking call to open inside the event loop by custom integration 'solcast_solar'
The problem
Since the latest update of HA lot of warnings on startup saying “Detected blocking call to open inside the event loop”.
What version of Solcast Integration has the issue?
v4.0.23
What version of Home Assistant are you using?
2024.6.0
Diagnostics information
No response
Logs debug/info/error output
Detected blocking call to open inside the event loop by custom integration 'solcast_solar' at custom_components/solcast_solar/solcastapi.py, line 97: with open(self._filename, "w") as f: (offender: /config/custom_components/solcast_solar/solcastapi.py, line 97: with open(self._filename, "w") as f:), please create a bug report at https://github.com/oziee/ha-solcast-solar/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/core.py", line 2741, in async_call response_data = await coro File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service return await target(service_call) File "/config/custom_components/solcast_solar/__init__.py", line 138, in handle_service_update_forecast await coordinator.service_event_update() File "/config/custom_components/solcast_solar/coordinator.py", line 67, in service_event_update await self.solcast.http_data(dopast=False) File "/config/custom_components/solcast_solar/solcastapi.py", line 554, in http_data await self.serialize_data() File "/config/custom_components/solcast_solar/solcastapi.py", line 97, in serialize_data with open(self._filename, "w") as f:
Additional information
This is not the only custom integration impacted in my list custom one’s, here is the same issue for another one and it can be related to this change of ha : https://developers.home-assistant.io/blog/2024/05/19/fix_zoneinfo_blocking_io/
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (1 by maintainers)
Commits related to this issue
- Fix for #14 changed dt_util.get_time_zone to dt_util.async_get_time_zone. Credit to @ma9mwah — committed to onetoomany/ha-solcast-solar by onetoomany 2 years ago
- Fix for https://github.com/BJReplay/ha-solcast-solar/issues/14 changed dt_util.get_time_zone to dt_util.async_get_time_zone. Credit to @ma9mwah — committed to michbeck100/ha-solcast-solar by michbeck100 2 years ago
- Fix for https://github.com/BJReplay/ha-solcast-solar/issues/14 changed dt_util.get_time_zone to dt_util.async_get_time_zone. Credit to @ma9mwah — committed to michbeck100/ha-solcast-solar by michbeck100 2 years ago
- Switch to aiofiles #14 — committed to autoSteve/ha-solcast-solar by autoSteve 2 years ago
- Use write(json.dumps()) instead of json.dump() #14 Using json.dump() was resulting in cache file zeroed. — committed to autoSteve/ha-solcast-solar by autoSteve 2 years ago
A pleasure, @changeofaspect, and a necessity given I run this code 😂. You’re 2024.6.0 ±ish, so would be great to have confirmation from someone on < 2024.6.0 (aside from me down-reving my code for the day).
Anyone? (Edit: good luck to me finding someone. The warning does not appear < 2024.6.0 so why seek help?..)
Many thanks. I have just tried await dt_util.async_get_time_zone(str(hass.config.time_zone)), and it doesn’t break it. However, when I poll the server, I get the original warning message appear:-
So it hasn’t fixed the original problem on my system. Now also on 2024.6.1 having updated earlier today.