Cleanup deprecated async_get_registry in acmeda (#72060)
This commit is contained in:
parent
5724d87c40
commit
2060f42818
2 changed files with 5 additions and 7 deletions
|
@ -2,10 +2,8 @@
|
||||||
import aiopulse
|
import aiopulse
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import entity
|
from homeassistant.helpers import device_registry as dr, entity, entity_registry as er
|
||||||
from homeassistant.helpers.device_registry import async_get_registry as get_dev_reg
|
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
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
|
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."""
|
"""Unregister from entity and device registry and call entity remove function."""
|
||||||
LOGGER.error("Removing %s %s", self.__class__.__name__, self.unique_id)
|
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:
|
if self.entity_id in ent_registry.entities:
|
||||||
ent_registry.async_remove(self.entity_id)
|
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)})
|
device = dev_registry.async_get_device(identifiers={(DOMAIN, self.unique_id)})
|
||||||
if device is not None:
|
if device is not None:
|
||||||
dev_registry.async_update_device(
|
dev_registry.async_update_device(
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
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 homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
@ -36,7 +36,7 @@ def async_add_acmeda_entities(
|
||||||
|
|
||||||
async def update_devices(hass: HomeAssistant, config_entry: ConfigEntry, api):
|
async def update_devices(hass: HomeAssistant, config_entry: ConfigEntry, api):
|
||||||
"""Tell hass that device info has been updated."""
|
"""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():
|
for api_item in api.values():
|
||||||
# Update Device name
|
# Update Device name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue