mrk-its / homeassistant-blitzortung

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

No lightning geo_location events get created running version 1.3.1 in Core 2024.3.3 (docker). #90

Closed BJReplay closed 2 months ago

BJReplay commented 3 months ago

Service info Lightning Detector Version: 1.3.1

Core 2024.3.3 Frontend 20240307.0

No lightning geo_location events get created.

It looks like there's a clash between HA core 2024.3.3 and the lightning detector version 1.3.1

I set up last night with a very wide radius (5000 km) and got errors, but now that we have a storm nearby, I'm seeing the same error with close by strikes.

Debug logging lists the same sequence of errors every time there is a strike.

2024-04-01 13:46:09.300 DEBUG (SyncWorker_63) [custom_components.blitzortung] ligntning data: {'time': 1711939567071387400, 'lat': -37.50826, 'lon': 145.656509, 'alt': 0, 'pol': 0, 'mds': 14662, 'mcg': 109, 'status': 0, 'region': 2, 'delay': 2.4, 'lonc': 0, 'latc': 0, 'sig_num': 18, 'distance': 71.5, 'azimuth': 57}
2024-04-01 13:46:09.300 DEBUG (SyncWorker_63) [custom_components.blitzortung.geo_location] geo_location lightning: {'time': 1711939567071387400, 'lat': -37.50826, 'lon': 145.656509, 'alt': 0, 'pol': 0, 'mds': 14662, 'mcg': 109, 'status': 0, 'region': 2, 'delay': 2.4, 'lonc': 0, 'latc': 0, 'sig_num': 18, 'distance': 71.5, 'azimuth': 57}
2024-04-01 13:46:09.300 DEBUG (SyncWorker_63) [custom_components.blitzortung.geo_location] tracked lightnings: 12
2024-04-01 13:46:19.220 DEBUG (MainThread) [custom_components.blitzortung.mqtt] Received message on blitzortung/1.1/r/1/n/u/9/4/j/0/c/t/r/w: b'{"time": 1711939576150236000, "lat": -38.57284, "lon": 144.543074, "alt": 0, "pol": 0, "mds": 3640, "mcg": 250, "status": 0, "region": 2, "delay": 3.3, "lonc": 0, "latc": 0, "sig_num": 23}'
2024-04-01 13:46:19.222 DEBUG (SyncWorker_27) [custom_components.blitzortung] ligntning data: {'time': 1711939576150236000, 'lat': -38.57284, 'lon': 144.543074, 'alt': 0, 'pol': 0, 'mds': 3640, 'mcg': 250, 'status': 0, 'region': 2, 'delay': 3.3, 'lonc': 0, 'latc': 0, 'sig_num': 23, 'distance': 88.2, 'azimuth': 205}
2024-04-01 13:46:19.222 DEBUG (SyncWorker_27) [custom_components.blitzortung.geo_location] geo_location lightning: {'time': 1711939576150236000, 'lat': -38.57284, 'lon': 144.543074, 'alt': 0, 'pol': 0, 'mds': 3640, 'mcg': 250, 'status': 0, 'region': 2, 'delay': 3.3, 'lonc': 0, 'latc': 0, 'sig_num': 23, 'distance': 88.2, 'azimuth': 205}
2024-04-01 13:46:19.223 DEBUG (SyncWorker_27) [custom_components.blitzortung.geo_location] tracked lightnings: 13
2024-04-01 13:46:36.793 ERROR (Recorder) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 625, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entities
    async with self.hass.timeout.async_timeout(timeout, self.domain):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/timeout.py", line 469, in async_timeout
    current_task: asyncio.Task[Any] | None = asyncio.current_task()
                                             ^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
2024-04-01 13:46:36.802 WARNING (Recorder) [py.warnings] /usr/local/lib/python3.12/site-packages/sqlalchemy/orm/mapper.py:3936: RuntimeWarning: coroutine 'EntityPlatform._async_add_entity' was never awaited
  visited_states: Set[InstanceState[Any]] = set()

2024-04-01 13:46:36.803 ERROR (Recorder) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 625, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entities
    async with self.hass.timeout.async_timeout(timeout, self.domain):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/timeout.py", line 469, in async_timeout
    current_task: asyncio.Task[Any] | None = asyncio.current_task()
                                             ^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
AdamGit69 commented 3 months ago

Thanks for posting! I've had this working for while now but just noticed that while we are having a big storm here now, the entities for the lightning counter, distance etc. still work and my automations still tell me when there is a close strike however I have the exact same issue that I was just chasing, nothing is created on the map anymore... Not sure when it stopped working as it has been a while between storms for me but I am on HA core 2024.3.3 and lightning detector version 1.3.1. My logs looks similar too:


2024-04-01 14:16:02.227 DEBUG (MainThread) [custom_components.blitzortung.mqtt] Received message on blitzortung/1.1/r/1/r/f/d/0/u/r/b/q/x/u: b'{"time": 1711941359684313600, "lat": PRIVATE "lon": PRIVATE "alt": 0, "pol": 0, "mds": 14913, "mcg": 114, "status": 0, "region": 2, "delay": 2.3, "lonc": 0, "latc": 0, "sig_num": 27}'
2024-04-01 14:16:02.231 DEBUG (SyncWorker_59) [custom_components.blitzortung] ligntning data: {'time': 1711941359684313600, 'lat': PRIVATE, 'lon': PRIVATE, 'alt': 0, 'pol': 0, 'mds': 14913, 'mcg': 114, 'status': 0, 'region': 2, 'delay': 2.3, 'lonc': 0, 'latc': 0, 'sig_num': 27, 'distance': 36.1, 'azimuth': 144}
2024-04-01 14:16:02.231 DEBUG (SyncWorker_59) [custom_components.blitzortung.geo_location] geo_location lightning: {'time': 1711941359684313600, 'lat': PRIVATE, 'lon': PRIVATE, 'alt': 0, 'pol': 0, 'mds': 14913, 'mcg': 114, 'status': 0, 'region': 2, 'delay': 2.3, 'lonc': 0, 'latc': 0, 'sig_num': 27, 'distance': 36.1, 'azimuth': 144}
2024-04-01 14:16:02.232 DEBUG (SyncWorker_59) [custom_components.blitzortung.geo_location] tracked lightnings: 9

2024-04-01 14:16:04.929 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 625, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entities
    async with self.hass.timeout.async_timeout(timeout, self.domain):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/timeout.py", line 469, in async_timeout
    current_task: asyncio.Task[Any] | None = asyncio.current_task()
                                             ^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
gabrymed commented 3 months ago

Same issue for me, nothing is created on the map anymore.

ezfrag2021 commented 3 months ago

Same for me. Everything working except the LS symbols on the map no longer appear.

scottbob09 commented 3 months ago

Thanks for posting! I've had this working for while now but just noticed that while we are having a big storm here now, the entities for the lightning counter, distance etc. still work and my automations still tell me when there is a close strike however I have the exact same issue that I was just chasing, nothing is created on the map anymore... Not sure when it stopped working as it has been a while between storms for me but I am on HA core 2024.3.3 and lightning detector version 1.3.1. My logs looks similar too:

2024-04-01 14:16:02.227 DEBUG (MainThread) [custom_components.blitzortung.mqtt] Received message on blitzortung/1.1/r/1/r/f/d/0/u/r/b/q/x/u: b'{"time": 1711941359684313600, "lat": PRIVATE "lon": PRIVATE "alt": 0, "pol": 0, "mds": 14913, "mcg": 114, "status": 0, "region": 2, "delay": 2.3, "lonc": 0, "latc": 0, "sig_num": 27}'
2024-04-01 14:16:02.231 DEBUG (SyncWorker_59) [custom_components.blitzortung] ligntning data: {'time': 1711941359684313600, 'lat': PRIVATE, 'lon': PRIVATE, 'alt': 0, 'pol': 0, 'mds': 14913, 'mcg': 114, 'status': 0, 'region': 2, 'delay': 2.3, 'lonc': 0, 'latc': 0, 'sig_num': 27, 'distance': 36.1, 'azimuth': 144}
2024-04-01 14:16:02.231 DEBUG (SyncWorker_59) [custom_components.blitzortung.geo_location] geo_location lightning: {'time': 1711941359684313600, 'lat': PRIVATE, 'lon': PRIVATE, 'alt': 0, 'pol': 0, 'mds': 14913, 'mcg': 114, 'status': 0, 'region': 2, 'delay': 2.3, 'lonc': 0, 'latc': 0, 'sig_num': 27, 'distance': 36.1, 'azimuth': 144}
2024-04-01 14:16:02.232 DEBUG (SyncWorker_59) [custom_components.blitzortung.geo_location] tracked lightnings: 9

2024-04-01 14:16:04.929 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 625, in async_add_entities
    await add_func(coros, entities, timeout)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entities
    async with self.hass.timeout.async_timeout(timeout, self.domain):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/timeout.py", line 469, in async_timeout
    current_task: asyncio.Task[Any] | None = asyncio.current_task()
                                             ^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop

Seems like the error is with the upgrade in the new core... Haven't found a changelog that this cooresponds to besides the python SQL stuff.

sqlalchemy/orm/mapper.py:3936: RuntimeWarning: coroutine 'EntityPlatform._async_add_entity' was never awaited

r1chards commented 3 months ago

Same thing here, stopped working. I managed to get this working by addding a device tracker but if I remember correctly this should just happen automatically and show the LS on the map, without having to creat a separate automation.

BJReplay commented 3 months ago

Judging by the errors being logged, and the commit history for entity_platform.py, and the release history for HA core, this commit for this PR has led to this failure.

I don't know enough to speculate more about what has caused this, but it looks like there are two changes: eager_start=True, at L483 in entity_platform.py and L499 in entity_platform.py and results = await asyncio.gather(*tasks, return_exceptions=True)

The definition of async_add_entities states

        """Add entities for a single platform async.

        This method must be run in the event loop.
        """

and the error message finishes with RuntimeError: no running event loop

scottbob09 commented 3 months ago

Judging by the errors being logged, and the commit history for entity_platform.py, and the release history for HA core, this commit for this PR has led to this failure.

I don't know enough to speculate more about what has caused this, but it looks like there are two changes: eager_start=True, at L483 in entity_platform.py and L499 in entity_platform.py and results = await asyncio.gather(*tasks, return_exceptions=True)

Just another instance of something that should have rolled to dev or beta before rolling it into production CORE.

scottbob09 commented 2 months ago

2024.4.3 not fixed. I tried mashing the code, but its beyond my skills.

mrk-its commented 2 months ago

fixed by https://github.com/mrk-its/homeassistant-blitzortung/commit/f9021aac8383e6ce4798f1f206b5b96c9da41463

BJReplay commented 2 months ago

Will test later today (I will find a storm and set up the integration as if I am nearby).

Thanks.

BJReplay commented 2 months ago

Thank you so much. Changed my location to Port Vila and the map is recording strikes. Thanks so much for this integration and for the fix.

gabrymed commented 2 months ago

Thanks for the fix!