From 49ad527a371c743cc698175db313f3bb65429c67 Mon Sep 17 00:00:00 2001 From: Malte Franken <exxamalte@users.noreply.github.com> Date: Thu, 29 Aug 2019 00:42:39 +1000 Subject: [PATCH] Fix WWLLN entity management (#26250) * added debug logging * fixed manager to keep track of managed external ids --- homeassistant/components/wwlln/geo_location.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/homeassistant/components/wwlln/geo_location.py b/homeassistant/components/wwlln/geo_location.py index 661972ff437..e8dd7ec08c7 100644 --- a/homeassistant/components/wwlln/geo_location.py +++ b/homeassistant/components/wwlln/geo_location.py @@ -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.""" -- GitLab