From 13f4393042021ff47adf23a3cba931ab156ba588 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 29 Apr 2020 00:58:55 -0500 Subject: [PATCH] Fix flapping reload tests (#34837) --- homeassistant/helpers/entity.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 738b49f4c54..b5d36f6a2f5 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -493,13 +493,14 @@ class Entity(ABC): async def async_remove(self) -> None: """Remove entity from Home Assistant.""" assert self.hass is not None - await self.async_internal_will_remove_from_hass() - await self.async_will_remove_from_hass() if self._on_remove is not None: while self._on_remove: self._on_remove.pop()() + await self.async_internal_will_remove_from_hass() + await self.async_will_remove_from_hass() + self.hass.states.async_remove(self.entity_id, context=self._context) async def async_added_to_hass(self) -> None: