mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Cleanup deprecated async_get_registry in uptimerobot (#72076)
This commit is contained in:
parent
2851540453
commit
5724d87c40
@ -12,12 +12,8 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
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.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 homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import API_ATTR_OK, COORDINATOR_UPDATE_INTERVAL, DOMAIN, LOGGER, PLATFORMS
|
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"
|
"Wrong API key type detected, use the 'main' API key"
|
||||||
)
|
)
|
||||||
uptime_robot_api = UptimeRobot(key, async_get_clientsession(hass))
|
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.data[DOMAIN][entry.entry_id] = coordinator = UptimeRobotDataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
@ -67,7 +63,7 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry_id: str,
|
config_entry_id: str,
|
||||||
dev_reg: DeviceRegistry,
|
dev_reg: dr.DeviceRegistry,
|
||||||
api: UptimeRobot,
|
api: UptimeRobot,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize coordinator."""
|
"""Initialize coordinator."""
|
||||||
@ -97,7 +93,7 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
current_monitors = {
|
current_monitors = {
|
||||||
list(device.identifiers)[0][1]
|
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
|
self._device_registry, self._config_entry_id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user