diff --git a/homeassistant/components/wwlln/geo_location.py b/homeassistant/components/wwlln/geo_location.py index 661972ff4371ff6977d454ddbc5ecd1bd4139148..e8dd7ec08c774cf61f9fa4cc32ea7f0927c2f79b 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."""