mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix WWLLN entity management (#26250)
* added debug logging * fixed manager to keep track of managed external ids
This commit is contained in:
parent
a28e644def
commit
49ad527a37
@ -88,6 +88,7 @@ class WWLLNEventManager:
|
||||
@callback
|
||||
def _create_events(self, ids_to_create):
|
||||
"""Create new geo location events."""
|
||||
_LOGGER.debug("Going to create %s", ids_to_create)
|
||||
events = []
|
||||
for strike_id in ids_to_create:
|
||||
strike = self._strikes[strike_id]
|
||||
@ -106,6 +107,7 @@ class WWLLNEventManager:
|
||||
@callback
|
||||
def _remove_events(self, ids_to_remove):
|
||||
"""Remove old geo location events."""
|
||||
_LOGGER.debug("Going to remove %s", ids_to_remove)
|
||||
for strike_id in ids_to_remove:
|
||||
async_dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(strike_id))
|
||||
|
||||
@ -136,12 +138,17 @@ class WWLLNEventManager:
|
||||
return
|
||||
|
||||
new_strike_ids = set(self._strikes)
|
||||
# Remove all managed entities that are not in the latest update anymore.
|
||||
ids_to_remove = self._managed_strike_ids.difference(new_strike_ids)
|
||||
self._remove_events(ids_to_remove)
|
||||
|
||||
# Create new entities for all strikes that are not managed entities yet.
|
||||
ids_to_create = new_strike_ids.difference(self._managed_strike_ids)
|
||||
self._create_events(ids_to_create)
|
||||
|
||||
# Store all external IDs of all managed strikes.
|
||||
self._managed_strike_ids = new_strike_ids
|
||||
|
||||
|
||||
class WWLLNEvent(GeolocationEvent):
|
||||
"""Define a lightning strike event."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user