diff --git a/homeassistant/components/gdacs/geo_location.py b/homeassistant/components/gdacs/geo_location.py index 31c3ba4138c..f434645ca20 100644 --- a/homeassistant/components/gdacs/geo_location.py +++ b/homeassistant/components/gdacs/geo_location.py @@ -11,6 +11,7 @@ from homeassistant.const import ( ) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.util.unit_system import IMPERIAL_SYSTEM from .const import DEFAULT_ICON, DOMAIN, FEED @@ -107,6 +108,9 @@ class GdacsEvent(GeolocationEvent): """Call when entity will be removed from hass.""" self._remove_signal_delete() self._remove_signal_update() + # Remove from entity registry. + entity_registry = await async_get_registry(self.hass) + entity_registry.async_remove(self.entity_id) @callback def _delete_callback(self): diff --git a/tests/components/gdacs/test_geo_location.py b/tests/components/gdacs/test_geo_location.py index c426b081e21..255a2c50946 100644 --- a/tests/components/gdacs/test_geo_location.py +++ b/tests/components/gdacs/test_geo_location.py @@ -29,6 +29,7 @@ from homeassistant.const import ( CONF_RADIUS, EVENT_HOMEASSISTANT_START, ) +from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from homeassistant.util.unit_system import IMPERIAL_SYSTEM @@ -97,6 +98,8 @@ async def test_setup(hass): all_states = hass.states.async_all() # 3 geolocation and 1 sensor entities assert len(all_states) == 4 + entity_registry = await async_get_registry(hass) + assert len(entity_registry.entities) == 4 state = hass.states.get("geo_location.drought_name_1") assert state is not None @@ -184,6 +187,7 @@ async def test_setup(hass): all_states = hass.states.async_all() assert len(all_states) == 1 + assert len(entity_registry.entities) == 1 async def test_setup_imperial(hass):