mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Explicitly pass in the config_entry in pyload coordinator (#138031)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
62461d7525
commit
552a5b1bb1
@ -6,7 +6,6 @@ from aiohttp import CookieJar
|
||||
from pyloadapi.api import PyLoadAPI
|
||||
from pyloadapi.exceptions import CannotConnect, InvalidAuth, ParserError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
@ -21,12 +20,10 @@ from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import PyLoadCoordinator
|
||||
from .coordinator import PyLoadConfigEntry, PyLoadCoordinator
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.BUTTON, Platform.SENSOR, Platform.SWITCH]
|
||||
|
||||
type PyLoadConfigEntry = ConfigEntry[PyLoadCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: PyLoadConfigEntry) -> bool:
|
||||
"""Set up pyLoad from a config entry."""
|
||||
@ -66,7 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: PyLoadConfigEntry) -> bo
|
||||
translation_key="setup_authentication_exception",
|
||||
translation_placeholders={CONF_USERNAME: entry.data[CONF_USERNAME]},
|
||||
) from e
|
||||
coordinator = PyLoadCoordinator(hass, pyloadapi)
|
||||
coordinator = PyLoadCoordinator(hass, entry, pyloadapi)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
@ -14,8 +14,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import PyLoadConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import PyLoadConfigEntry
|
||||
from .entity import BasePyLoadEntity
|
||||
|
||||
|
||||
|
@ -34,16 +34,22 @@ class PyLoadData:
|
||||
free_space: int
|
||||
|
||||
|
||||
type PyLoadConfigEntry = ConfigEntry[PyLoadCoordinator]
|
||||
|
||||
|
||||
class PyLoadCoordinator(DataUpdateCoordinator[PyLoadData]):
|
||||
"""pyLoad coordinator."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
config_entry: PyLoadConfigEntry
|
||||
|
||||
def __init__(self, hass: HomeAssistant, pyload: PyLoadAPI) -> None:
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: PyLoadConfigEntry, pyload: PyLoadAPI
|
||||
) -> None:
|
||||
"""Initialize pyLoad coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=SCAN_INTERVAL,
|
||||
)
|
||||
|
@ -9,8 +9,7 @@ from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import PyLoadConfigEntry
|
||||
from .coordinator import PyLoadData
|
||||
from .coordinator import PyLoadConfigEntry, PyLoadData
|
||||
|
||||
TO_REDACT = {CONF_USERNAME, CONF_PASSWORD, CONF_HOST}
|
||||
|
||||
|
@ -17,9 +17,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import PyLoadConfigEntry
|
||||
from .const import UNIT_DOWNLOADS
|
||||
from .coordinator import PyLoadData
|
||||
from .coordinator import PyLoadConfigEntry, PyLoadData
|
||||
from .entity import BasePyLoadEntity
|
||||
|
||||
|
||||
|
@ -18,9 +18,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import PyLoadConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import PyLoadData
|
||||
from .coordinator import PyLoadConfigEntry, PyLoadData
|
||||
from .entity import BasePyLoadEntity
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user