mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Explicitly pass in the config_entry in steam_online coordinator (#137929)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
93dad987f8
commit
071b46055b
@ -2,19 +2,17 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import SteamDataUpdateCoordinator
|
||||
from .coordinator import SteamConfigEntry, SteamDataUpdateCoordinator
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
type SteamConfigEntry = ConfigEntry[SteamDataUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: SteamConfigEntry) -> bool:
|
||||
"""Set up Steam from a config entry."""
|
||||
coordinator = SteamDataUpdateCoordinator(hass)
|
||||
coordinator = SteamDataUpdateCoordinator(hass, entry)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
entry.runtime_data = coordinator
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
@ -18,8 +18,8 @@ from homeassistant.const import CONF_API_KEY, Platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||
|
||||
from . import SteamConfigEntry
|
||||
from .const import CONF_ACCOUNT, CONF_ACCOUNTS, DOMAIN, LOGGER, PLACEHOLDERS
|
||||
from .coordinator import SteamConfigEntry
|
||||
|
||||
# To avoid too long request URIs, the amount of ids to request is limited
|
||||
MAX_IDS_TO_REQUEST = 275
|
||||
|
@ -3,11 +3,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import steam
|
||||
from steam.api import _interface_method as INTMethod
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
@ -15,8 +15,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
|
||||
from .const import CONF_ACCOUNTS, DOMAIN, LOGGER
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import SteamConfigEntry
|
||||
type SteamConfigEntry = ConfigEntry[SteamDataUpdateCoordinator]
|
||||
|
||||
|
||||
class SteamDataUpdateCoordinator(
|
||||
@ -26,11 +25,12 @@ class SteamDataUpdateCoordinator(
|
||||
|
||||
config_entry: SteamConfigEntry
|
||||
|
||||
def __init__(self, hass: HomeAssistant) -> None:
|
||||
def __init__(self, hass: HomeAssistant, config_entry: SteamConfigEntry) -> None:
|
||||
"""Initialize the coordinator."""
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=30),
|
||||
)
|
||||
|
@ -12,7 +12,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.util.dt import utc_from_timestamp
|
||||
|
||||
from . import SteamConfigEntry
|
||||
from .const import (
|
||||
CONF_ACCOUNTS,
|
||||
STEAM_API_URL,
|
||||
@ -21,7 +20,7 @@ from .const import (
|
||||
STEAM_MAIN_IMAGE_FILE,
|
||||
STEAM_STATUSES,
|
||||
)
|
||||
from .coordinator import SteamDataUpdateCoordinator
|
||||
from .coordinator import SteamConfigEntry, SteamDataUpdateCoordinator
|
||||
from .entity import SteamEntity
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user