mrk-its / homeassistant-blitzortung

Custom Component for fetching lightning data from blitzortung.org
MIT License
186 stars 38 forks source link

blitzortung is doing a non-thread safe operation #89

Closed Mariusthvdb closed 3 months ago

Mariusthvdb commented 4 months ago
2024-03-23 20:28:57.295 ERROR (SyncWorker_7) [homeassistant.util.logging] Exception in _on_connection_change when dispatching 'blitzortung_mqtt_connected': ()
Traceback (most recent call last):
  File "/config/custom_components/blitzortung/__init__.py", line 222, in _on_connection_change
    sensor.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1175, in _async_write_ha_state
    hass.states.async_set(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1964, in async_set
    self._bus.async_fire(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1290, in async_fire
    self._hass.async_add_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 603, in async_add_hass_job
    task = self.loop.create_task(hassjob.target(*args), name=hassjob.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 457, in create_task
    task = tasks.Task(coro, loop=self, name=name, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
    self._check_thread()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 832, in _check_thread
    raise RuntimeError(
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one

which can crash the whole system, dixit core HA devs...

please have a look to fix this currenty, have to disable the integration because of it

andrewjswan commented 3 months ago

https://github.com/mrk-its/homeassistant-blitzortung/issues/91

mrk-its commented 3 months ago

I'll take a look on it soon, sorry for delay. Thanks!

mrk-its commented 3 months ago

closing as duplicate of #85. Can you check current version (1.3.2)?