Mobile app to update entity registry on re-register sensors (#58378)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Paulus Schoutsen 2021-10-31 20:21:46 -07:00 committed by GitHub
parent 4e419d8c6f
commit a122cbab61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 128 additions and 39 deletions

View file

@ -38,7 +38,6 @@ from homeassistant.core import CALLBACK_TYPE, Context, HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError, NoEntitySpecifiedError
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity_platform import EntityPlatform
from homeassistant.helpers.entity_registry import RegistryEntry
from homeassistant.helpers.event import Event, async_track_entity_registry_updated_event
from homeassistant.helpers.typing import StateType
from homeassistant.loader import bind_hass
@ -227,7 +226,7 @@ class Entity(ABC):
parallel_updates: asyncio.Semaphore | None = None
# Entry in the entity registry
registry_entry: RegistryEntry | None = None
registry_entry: er.RegistryEntry | None = None
# Hold list for functions to call on remove.
_on_remove: list[CALLBACK_TYPE] | None = None
@ -806,7 +805,7 @@ class Entity(ABC):
if data["action"] != "update":
return
ent_reg = await self.hass.helpers.entity_registry.async_get_registry()
ent_reg = er.async_get(self.hass)
old = self.registry_entry
self.registry_entry = ent_reg.async_get(data["entity_id"])
assert self.registry_entry is not None