mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Explicitly pass in the config_entry in minecraft_server coordinator (#138086)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
a60f30509a
commit
200eb9a63d
@ -10,14 +10,7 @@ import dns.rdataclass
|
||||
import dns.rdatatype
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
CONF_PORT,
|
||||
CONF_TYPE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_HOST, CONF_PORT, CONF_TYPE, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
@ -58,7 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
raise ConfigEntryNotReady(f"Initialization failed: {error}") from error
|
||||
|
||||
# Create coordinator instance.
|
||||
coordinator = MinecraftServerCoordinator(hass, entry.data[CONF_NAME], api)
|
||||
coordinator = MinecraftServerCoordinator(hass, entry, api)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
# Store coordinator instance.
|
||||
|
@ -5,6 +5,8 @@ from __future__ import annotations
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
@ -23,13 +25,21 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class MinecraftServerCoordinator(DataUpdateCoordinator[MinecraftServerData]):
|
||||
"""Minecraft Server data update coordinator."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, name: str, api: MinecraftServer) -> None:
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
api: MinecraftServer,
|
||||
) -> None:
|
||||
"""Initialize coordinator instance."""
|
||||
self._api = api
|
||||
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
name=name,
|
||||
name=config_entry.data[CONF_NAME],
|
||||
config_entry=config_entry,
|
||||
logger=_LOGGER,
|
||||
update_interval=SCAN_INTERVAL,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user