Fix flapping reload tests (#34837)

pull/34847/head
J. Nick Koston 2020-04-29 00:58:55 -05:00 committed by GitHub
parent 942cd7caa5
commit 13f4393042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -493,13 +493,14 @@ class Entity(ABC):
async def async_remove(self) -> None: async def async_remove(self) -> None:
"""Remove entity from Home Assistant.""" """Remove entity from Home Assistant."""
assert self.hass is not None 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: if self._on_remove is not None:
while self._on_remove: while self._on_remove:
self._on_remove.pop()() 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) self.hass.states.async_remove(self.entity_id, context=self._context)
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None: