Cleanup deprecated async_get_registry in uptimerobot (#72076)

pull/72083/head
epenet 2022-05-18 11:46:09 +02:00 committed by GitHub
parent 2851540453
commit 5724d87c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -12,12 +12,8 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import (
DeviceRegistry,
async_entries_for_config_entry,
async_get_registry,
)
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import API_ATTR_OK, COORDINATOR_UPDATE_INTERVAL, DOMAIN, LOGGER, PLATFORMS
@ -32,7 +28,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"Wrong API key type detected, use the 'main' API key"
)
uptime_robot_api = UptimeRobot(key, async_get_clientsession(hass))
dev_reg = await async_get_registry(hass)
dev_reg = dr.async_get(hass)
hass.data[DOMAIN][entry.entry_id] = coordinator = UptimeRobotDataUpdateCoordinator(
hass,
@ -67,7 +63,7 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator):
self,
hass: HomeAssistant,
config_entry_id: str,
dev_reg: DeviceRegistry,
dev_reg: dr.DeviceRegistry,
api: UptimeRobot,
) -> None:
"""Initialize coordinator."""
@ -97,7 +93,7 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator):
current_monitors = {
list(device.identifiers)[0][1]
for device in async_entries_for_config_entry(
for device in dr.async_entries_for_config_entry(
self._device_registry, self._config_entry_id
)
}