Cleanup deprecated async_get_registry in acmeda (#72060)

This commit is contained in:
epenet 2022-05-18 11:55:08 +02:00 committed by GitHub
parent 5724d87c40
commit 2060f42818
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -2,10 +2,8 @@
import aiopulse
from homeassistant.core import callback
from homeassistant.helpers import entity
from homeassistant.helpers.device_registry import async_get_registry as get_dev_reg
from homeassistant.helpers import device_registry as dr, entity, entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_registry import async_get_registry as get_ent_reg
from .const import ACMEDA_ENTITY_REMOVE, DOMAIN, LOGGER
@ -21,11 +19,11 @@ class AcmedaBase(entity.Entity):
"""Unregister from entity and device registry and call entity remove function."""
LOGGER.error("Removing %s %s", self.__class__.__name__, self.unique_id)
ent_registry = await get_ent_reg(self.hass)
ent_registry = er.async_get(self.hass)
if self.entity_id in ent_registry.entities:
ent_registry.async_remove(self.entity_id)
dev_registry = await get_dev_reg(self.hass)
dev_registry = dr.async_get(self.hass)
device = dev_registry.async_get_device(identifiers={(DOMAIN, self.unique_id)})
if device is not None:
dev_registry.async_update_device(

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import async_get_registry as get_dev_reg
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN, LOGGER
@ -36,7 +36,7 @@ def async_add_acmeda_entities(
async def update_devices(hass: HomeAssistant, config_entry: ConfigEntry, api):
"""Tell hass that device info has been updated."""
dev_registry = await get_dev_reg(hass)
dev_registry = dr.async_get(hass)
for api_item in api.values():
# Update Device name