Clean up use of deprecated async_get_registry methods (#72001)

This commit is contained in:
Franck Nijhof 2022-05-17 13:40:19 +02:00 committed by GitHub
parent 39b27e4d38
commit 7d2deae592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 51 additions and 51 deletions

View File

@ -57,7 +57,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Alarm control panel devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# Get all the integrations entities for this device

View File

@ -64,7 +64,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Alarm control panel devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -60,7 +60,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Alarm control panel devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers: list[dict[str, str]] = []
# Get all the integrations entities for this device

View File

@ -37,7 +37,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Arcam FMJ Receiver control devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -43,7 +43,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# Get all the integrations entities for this device

View File

@ -45,7 +45,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -67,7 +67,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -63,7 +63,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Cover devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# Get all the integrations entities for this device

View File

@ -66,7 +66,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Cover devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions: list[dict[str, str]] = []
# Get all the integrations entities for this device

View File

@ -76,7 +76,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Cover devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -33,7 +33,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Device tracker devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -41,7 +41,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Device Tracker devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -34,7 +34,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Fan devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -35,7 +35,7 @@ async def async_setup_entry(
] = async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
# Restore previously loaded devices
dev_reg = await device_registry.async_get_registry(hass)
dev_reg = device_registry.async_get(hass)
dev_ids = {
identifier[1]
for device in dev_reg.devices.values()

View File

@ -45,7 +45,7 @@ async def async_setup_entry(
] = async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
# Restore previously loaded devices
dev_reg = await device_registry.async_get_registry(hass)
dev_reg = device_registry.async_get(hass)
dev_ids = {
identifier[1]
for device in dev_reg.devices.values()

View File

@ -66,7 +66,7 @@ async def async_setup_entry(
# Initialize already tracked entities
tracked: set[str] = set()
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
known_entities: list[Entity] = []
track_wired_clients = router.config_entry.options.get(
CONF_TRACK_WIRED_CLIENTS, DEFAULT_TRACK_WIRED_CLIENTS

View File

@ -49,7 +49,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Humidifier devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN)
# Get all the integrations entities for this device

View File

@ -41,7 +41,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Humidifier devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = await toggle_entity.async_get_conditions(hass, device_id, DOMAIN)
# Get all the integrations entities for this device

View File

@ -61,7 +61,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Humidifier devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
# Get all the integrations entities for this device

View File

@ -40,7 +40,7 @@ async def async_setup_entry(
update_from_router()
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
# Restore devices that are not a part of active clients list.
restored = []
for entity_entry in registry.entities.values():

View File

@ -38,7 +38,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Kodi devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -426,7 +426,7 @@ class KodiEntity(MediaPlayerEntity):
version = (await self._kodi.get_application_properties(["version"]))["version"]
sw_version = f"{version['major']}.{version['minor']}"
dev_reg = await device_registry.async_get_registry(self.hass)
dev_reg = device_registry.async_get(self.hass)
device = dev_reg.async_get_device({(DOMAIN, self.unique_id)})
dev_reg.async_update_device(device.id, sw_version=sw_version)

View File

@ -34,7 +34,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Lock devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# Get all the integrations entities for this device

View File

@ -45,7 +45,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Lock devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -45,7 +45,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Lock devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -45,7 +45,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Media player devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -57,7 +57,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Media player entities."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = await entity.async_get_triggers(hass, device_id, DOMAIN)
# Get all the integration entities for this device

View File

@ -34,7 +34,7 @@ async def async_setup_entry(
tracked: dict[str, MikrotikHubTracker] = {}
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
# Restore clients that is not a part of active clients list.
for entity in registry.entities.values():

View File

@ -93,7 +93,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Netatmo devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
device_registry = await hass.helpers.device_registry.async_get_registry()
triggers = []

View File

@ -32,7 +32,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Number."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions: list[dict[str, str]] = []
# Get all the integrations entities for this device

View File

@ -26,7 +26,7 @@ async def async_setup_entry(
) -> None:
"""Set up OwnTracks based off an entry."""
# Restore previously loaded devices
dev_reg = await device_registry.async_get_registry(hass)
dev_reg = device_registry.async_get(hass)
dev_ids = {
identifier[1]
for device in dev_reg.devices.values()

View File

@ -116,7 +116,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# Migrate Version 2 -> Version 3: Update identifier format.
if version == 2:
# Prevent changing entity_id. Updates entity registry.
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
for entity_id, e_entry in registry.entities.items():
if e_entry.config_entry_id == entry.entry_id:

View File

@ -333,8 +333,8 @@ class PS4Device(MediaPlayerEntity):
# If cannot get status on startup, assume info from registry.
if status is None:
_LOGGER.info("Assuming status from registry")
e_registry = await entity_registry.async_get_registry(self.hass)
d_registry = await device_registry.async_get_registry(self.hass)
e_registry = entity_registry.async_get(self.hass)
d_registry = device_registry.async_get(self.hass)
for entity_id, entry in e_registry.entities.items():
if entry.config_entry_id == self._entry_id:
self._unique_id = entry.unique_id

View File

@ -44,7 +44,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
system_info = await hass.async_add_executor_job(ruckus.system_info)
registry = await device_registry.async_get_registry(hass)
registry = device_registry.async_get(hass)
ap_info = await hass.async_add_executor_job(ruckus.ap_info)
for device in ap_info[API_AP][API_ID].values():
registry.async_get_or_create(

View File

@ -38,7 +38,7 @@ async def async_setup_entry(
coordinator.async_add_listener(router_update)
)
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
restore_entities(registry, coordinator, entry, async_add_entities, tracked)

View File

@ -34,7 +34,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Select devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
return [
{
CONF_DEVICE_ID: device_id,

View File

@ -38,7 +38,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Select devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
return [
{
CONF_CONDITION: "device",

View File

@ -49,7 +49,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Select devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
return [
{
CONF_PLATFORM: "device",

View File

@ -87,7 +87,7 @@ async def async_restore_climate_entities(
) -> None:
"""Restore sleeping climate devices."""
ent_reg = await entity_registry.async_get_registry(hass)
ent_reg = entity_registry.async_get(hass)
entries = entity_registry.async_entries_for_config_entry(
ent_reg, config_entry.entry_id
)

View File

@ -134,7 +134,7 @@ async def async_restore_block_attribute_entities(
"""Restore block attributes entities."""
entities = []
ent_reg = await entity_registry.async_get_registry(hass)
ent_reg = entity_registry.async_get(hass)
entries = entity_registry.async_entries_for_config_entry(
ent_reg, config_entry.entry_id
)

View File

@ -144,7 +144,7 @@ async def async_setup_entry(
] = async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
# Restore previously loaded devices
dev_reg = await device_registry.async_get_registry(hass)
dev_reg = device_registry.async_get(hass)
dev_ids = {
identifier[1]
for device in dev_reg.devices.values()

View File

@ -30,7 +30,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Vacuum devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# Get all the integrations entities for this device

View File

@ -32,7 +32,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for Vacuum devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -40,7 +40,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Vacuum devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# Get all the integrations entities for this device

View File

@ -32,7 +32,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for Water Heater devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
for entry in entity_registry.async_entries_for_device(registry, device_id):

View File

@ -1549,7 +1549,7 @@ class EntityRegistryDisabledHandler:
async def _handle_entry_updated(self, event: Event) -> None:
"""Handle entity registry entry update."""
if self.registry is None:
self.registry = await entity_registry.async_get_registry(self.hass)
self.registry = entity_registry.async_get(self.hass)
entity_entry = self.registry.async_get(event.data["entity_id"])

View File

@ -823,7 +823,7 @@ def async_setup_cleanup(hass: HomeAssistant, dev_reg: DeviceRegistry) -> None:
async def cleanup() -> None:
"""Cleanup."""
ent_reg = await entity_registry.async_get_registry(hass)
ent_reg = entity_registry.async_get(hass)
async_cleanup(hass, dev_reg, ent_reg)
debounced_cleanup = Debouncer(

View File

@ -33,7 +33,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device actions for NEW_NAME devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
actions = []
# TODO Read this comment and remove it.

View File

@ -35,7 +35,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]:
"""List device conditions for NEW_NAME devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
conditions = []
# Get all the integrations entities for this device

View File

@ -41,7 +41,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for NEW_NAME devices."""
registry = await entity_registry.async_get_registry(hass)
registry = entity_registry.async_get(hass)
triggers = []
# TODO Read this comment and remove it.