pnbruckner / ha-sun2

Home Assistant Sun2 Sensor
The Unlicense
235 stars 22 forks source link

Blocking call in 2024.6.0 beta #127

Closed mhoogenbosch closed 5 months ago

mhoogenbosch commented 5 months ago

Upgrading to 2024.6.0beta results in an error in the logs:

2024-06-04 17:40:35.849 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'sun2' at custom_components/sun2/helpers.py, line 369: return getattr(loc, event.split("_")[1])(date_or_dttm) (offender: /usr/local/lib/python3.12/site-packages/pytz/__init__.py, line 108: return open(filename, 'rb')), please create a bug report at https://github.com/pnbruckner/ha-sun2/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 188, 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 2081, in _async_forward_entry_setup
    await entry.async_setup(self.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 "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 134, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 196, in async_setup_entry
    return await self._platforms[key].async_setup_entry(config_entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 333, in async_setup_entry
    return await self._async_setup_platform(async_create_setup_awaitable)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 363, in _async_setup_platform
    awaitable = create_eager_task(awaitable, loop=hass.loop)
  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 "/config/custom_components/sun2/helpers.py", line 513, in async_setup_entry
    cls(hass, entry, async_add_entities)
  File "/config/custom_components/sun2/helpers.py", line 418, in __init__
    async_add_entities(self._entities, True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 515, in _async_schedule_add_entities_for_entry
    task = self.config_entry.async_create_task(
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1134, in async_create_task
    task = hass.async_create_task_internal(
  File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal
    task = create_eager_task(target, name=name, loop=self.loop)
  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/helpers/entity_platform.py", line 649, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 555, in _async_add_and_update_entities
    tasks = [create_eager_task(coro, loop=self.hass.loop) for coro in coros]
  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/helpers/entity_platform.py", line 729, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update
    await self.async_update()
  File "/config/custom_components/sun2/helpers.py", line 318, in async_update
    self._update(dt_util.now(self._astral_data.loc_data.tzi))
  File "/config/custom_components/sun2/sensor.py", line 211, in _update
    self._yesterday = cast(Optional[_T], self._astral_event(cur_date - ONE_DAY))
  File "/config/custom_components/sun2/helpers.py", line 369, in _astral_event
    return getattr(loc, event.split("_")[1])(date_or_dttm)

Full log file:

home-assistant.zip

pnbruckner commented 5 months ago

Please update to the 3.3.2 release (from 4 days ago) and let me know if it solves the problem.

pnbruckner commented 5 months ago

Duplicate of #125

mhoogenbosch commented 5 months ago

My bad.. don't really get why it didn't show the update to 3.3.2, but yes, that solves it.

pnbruckner commented 5 months ago

don't really get why it didn't show the update to 3.3.2

What do you mean by "it"? Do you mean HACS? It should have. As far as I know, HACS should check for updates every 48 hours, and since the release was made 4 days earlier, it definitely did have time to notice.

mhoogenbosch commented 5 months ago

Yup, with it I mean HACS. Oh well.. I'm happy it is solved. Thanks for all you efforts!